Jenkins tweaks

This commit is contained in:
simon987 2019-03-24 20:33:37 -04:00
parent 4ffe805b8d
commit 841394ebac
6 changed files with 32 additions and 37 deletions

View File

@ -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 {

30
jenkins/Jenkinsfile vendored
View File

@ -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'
}
}
}

View File

@ -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

View File

@ -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)

View File

@ -1,2 +0,0 @@
#!/usr/bin/env bash
uwsgi od-database.ini

View File

@ -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):