diff --git a/README.md b/README.md index 4f3dc46..9d57a86 100644 --- a/README.md +++ b/README.md @@ -51,10 +51,8 @@ python3 app.py ## Running the web server with Nginx (production) * Install dependencies: ```bash -sudo apt install build-essential python-dev redis-server -sudo pip install uwsgi +sudo apt install build-essential python-dev redis-server uwsgi-plugin-python3 ``` -* Adjust the path in `od-database.ini` * Configure nginx (on Debian 9: `/etc/nginx/sites-enabled/default`): ```nginx server { diff --git a/jenkins/Jenkinsfile b/jenkins/Jenkinsfile index db44afe..8fd8f24 100644 --- a/jenkins/Jenkinsfile +++ b/jenkins/Jenkinsfile @@ -11,13 +11,37 @@ pipeline { stage('Build') { steps { sh './jenkins/build.sh' - stash includes: 'env/', name: 'env' } } stage('Deploy') { steps { - sshPut remote: remote, from: '.', into: 'oddb' - sshCommand remote: remote, command: 'chmod +x oddb/deploy.sh && ./oddb/deploy.sh' + sh 'echo $ODDB_CONFIG > config.py' + sshCommand remote: remote, command: "cd od-database && rm -rf env fold_to_ascii search static task_tracker_drone templates ws_bucket_client" + sshPut remote: remote, from: 'env', into: 'od-database' + sshPut remote: remote, from: 'fold_to_ascii', into: 'od-database' + sshPut remote: remote, from: 'search', into: 'od-database' + sshPut remote: remote, from: 'static', into: 'od-database' + sshPut remote: remote, from: 'task_tracker_drone', into: 'od-database' + sshPut remote: remote, from: 'templates', into: 'od-database' + sshPut remote: remote, from: 'ws_bucket_client', into: 'od-database' + sshPut remote: remote, from: '__init__.py', into: 'od-database' + sshPut remote: remote, from: 'api.py', into: 'od-database' + sshPut remote: remote, from: 'app.py', into: 'od-database' + sshPut remote: remote, from: 'captcha.py', into: 'od-database' + sshPut remote: remote, from: 'common.py', into: 'od-database' + sshPut remote: remote, from: 'database.py', into: 'od-database' + sshPut remote: remote, from: 'export.py', into: 'od-database' + sshPut remote: remote, from: 'init_script.sql', into: 'od-database' + sshPut remote: remote, from: 'od_util.py', into: 'od-database' + sshPut remote: remote, from: 'reddit_bot.py', into: 'od-database' + sshPut remote: remote, from: 'tasks.py', into: 'od-database' + sshPut remote: remote, from: 'template_filters.py', into: 'od-database' + sshPut remote: remote, from: 'uwsgi.py', into: 'od-database' + sshPut remote: remote, from: 'views.py', into: 'od-database' + sshPut remote: remote, from: 'config.py', into: 'od-database' + sshPut remote: remote, from: 'od-database.ini', into: 'od-database' + sshPut remote: remote, from: 'jenkins/deploy.sh', into: 'od-database' + sshCommand remote: remote, command: 'chmod +x od-database/deploy.sh && ./od-database/deploy.sh' } } } diff --git a/jenkins/deploy.sh b/jenkins/deploy.sh index 14e8954..e86fd0d 100755 --- a/jenkins/deploy.sh +++ b/jenkins/deploy.sh @@ -2,8 +2,8 @@ export ODDBROOT="od-database" -screen -S oddb -X quit +screen -S oddb_web -X quit echo "starting oddb_web" -screen -S tt_drone -d -m bash -c "cd ${ODDBROOT} && uwsgi od-database.ini" +screen -S oddb_web -d -m bash -c "cd ${ODDBROOT} && uwsgi od-database.ini" sleep 1 screen -list \ No newline at end of file diff --git a/restore.py b/restore.py deleted file mode 100644 index eb3ba6b..0000000 --- a/restore.py +++ /dev/null @@ -1,26 +0,0 @@ -import ujson - -from search.search import ElasticSearchEngine - -es = ElasticSearchEngine("od-database") -es.reset() - -with open("dump.json", "r") as f: - - buffer = list() - index_every = 10000 - - for line in f: - try: - doc = ujson.loads(line)["_source"] - buffer.append(doc) - - if len(buffer) >= index_every: - es._index(buffer) - buffer.clear() - - except Exception as e: - print("ERROR: " + str(e)) - - es._index(buffer) - diff --git a/startWSGI.sh b/startWSGI.sh deleted file mode 100644 index a7ad37d..0000000 --- a/startWSGI.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -uwsgi od-database.ini \ No newline at end of file diff --git a/views.py b/views.py index bffc112..d42b9b4 100644 --- a/views.py +++ b/views.py @@ -10,8 +10,9 @@ import captcha import config import od_util from common import db, taskManager, searchEngine, logger, require_role -from database import Task, Website +from database import Website from search.search import InvalidQueryException +from tasks import Task def setup_views(app):