diff --git a/docker/Dockerfile b/docker/Dockerfile index c84a3f8..c00277e 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,21 +1,15 @@ FROM realms/base # Packages -RUN add-apt-repository -y ppa:chris-lea/node.js && apt-get update -RUN apt-get install -y python build-essential git libpcre3-dev python-software-properties \ - python-pip python-virtualenv python-dev pkg-config curl libxml2-dev libxslt1-dev zlib1g-dev \ - libffi-dev nodejs libyaml-dev +RUN apt-get update && apt-get install -y build-essential python-pip python-virtualenv python-dev zlib1g-dev libffi-dev libyaml-dev -# Realms Code -RUN cd /home/deploy && git clone https://github.com/scragg0x/realms-wiki +# lxml deps +# libxml2-dev libxslt1-dev -# Bower stuff for frontend assets -RUN npm install -g bower -RUN bower --allow-root --config.cwd=/home/deploy/realms-wiki --config.directory=realms/static/vendor --config.interactive=false install - -# Virtualenv building +# Virtualenv RUN virtualenv /home/deploy/realms-wiki/.venv -RUN /home/deploy/realms-wiki/.venv/bin/pip install /home/deploy/realms-wiki + +RUN cd /home/deploy/realms-wiki && .venv/bin/pip install realms-wiki # Logging RUN mkdir /var/log/realms-wiki && chown deploy.deploy /var/log/realms-wiki diff --git a/docker/realms-wiki.sh b/docker/realms-wiki.sh index 48f9c72..5fc0318 100644 --- a/docker/realms-wiki.sh +++ b/docker/realms-wiki.sh @@ -1,9 +1,51 @@ -#!/bin/sh +#!/bin/bash + +limit nofile 65335 65335 + +respawn + +description "Realms Wiki" +author "scragg@gmail.com" chdir /home/deploy/realms-wiki +env PATH=/home/deploy/realms-wiki/.venv/bin:/usr/local/bin:/usr/bin:/bin:$PATH +export PATH + +env LC_ALL=en_US.UTF-8 +env GEVENT_RESOLVER=ares + +export LC_ALL +export GEVENT_RESOLVER + if [ "${REALMS_WIKI_CONFIG}" != "" ]; then realms-wiki configure ${REALMS_WIKI_CONFIG} fi -exec /sbin/setuser deploy /home/deploy/realms-wiki/.venv/bin/python manage.py run >>/var/log/realms-wiki/realms-wiki.log 2>&1 +if [ "${REALMS_WIKI_WORKERS}" == "" ]; then + REALMS_WIKI_WORKERS=3 +fi + +if [ "${REALMS_WIKI_PORT}" == "" ]; then + REALMS_WIKI_PORT=5000 +fi + +setuid deploy +setgid deploy + +start on runlevel [2345] +stop on runlevel [!2345] + +respawn + +exec gunicorn \ + --name realms-wiki \ + --access-logfile - \ + --error-logfile - \ + --worker-class gevent \ + --workers ${REALMS_WIKI_WORKERS} \ + --bind 0.0.0.0:${REALMS_WIKI_PORT} \ + --user deploy \ + --group deploy \ + --chdir /home/deploy/realms-wiki \ + 'realms:create_app()' >>/var/log/realms-wiki/realms-wiki.log 2>&1 diff --git a/install.sh b/install.sh index 457f1a3..275b651 100755 --- a/install.sh +++ b/install.sh @@ -15,9 +15,12 @@ sudo apt-get install -y software-properties-common python-software-properties sudo add-apt-repository -y ppa:chris-lea/node.js sudo apt-get update sudo apt-get install -y python build-essential pkg-config git \ -python-pip python-virtualenv python-dev libxml2-dev libxslt1-dev zlib1g-dev \ +python-pip python-virtualenv python-dev zlib1g-dev \ libffi-dev libyaml-dev libssl-dev nodejs +# lxml deps +# libxml2-dev libxslt1-dev + # Default cache is memoization # Redis diff --git a/realms/commands.py b/realms/commands.py index 608ec29..c7a2678 100644 --- a/realms/commands.py +++ b/realms/commands.py @@ -326,8 +326,8 @@ def restart(): def status(): """ Get server status """ - pid = is_running(get_pid()) - if not pid: + pid = get_pid() + if not is_running(pid): yellow("Server is not running") else: green("Server is running PID: %s" % pid) diff --git a/realms/modules/wiki/models.py b/realms/modules/wiki/models.py index dc7d515..a513755 100644 --- a/realms/modules/wiki/models.py +++ b/realms/modules/wiki/models.py @@ -1,13 +1,10 @@ import os import re -import lxml.html -from lxml.html.clean import Cleaner import ghdiff import gittle.utils import yaml from gittle import Gittle from dulwich.repo import NotGitRepository -from werkzeug.utils import escape, unescape from realms.lib.util import to_canonical from realms import cache from realms.lib.hook import HookMixin @@ -107,8 +104,6 @@ class Wiki(HookMixin): cname = to_canonical(name) filename = cname_to_filename(cname) - content = self.clean(content) - with open(self.path + "/" + filename, 'w') as f: f.write(content) @@ -129,50 +124,6 @@ class Wiki(HookMixin): return ret - def clean(self, content): - """Clean any HTML, this might not be necessary. - - :param content: Content of page. - :return: str - - """ - def escape_repl(m): - if m.group(1): - return "```" + escape(m.group(1)) + "```" - - def unescape_repl(m): - if m.group(1): - return "```" + unescape(m.group(1)) + "```" - - # prevents p tag from being added, we remove this later - content = '