webplatform / annotation-service

Hypothes.is’ container project to customize for notes.webplatform.org
1 stars 0 forks source link

Define appropriate installation configurations for production environment #10

Closed renoirb closed 9 years ago

renoirb commented 9 years ago

To run the current version I’m using a bootstraper and an init script to ensure the service is running. Is there things I should add/adjust to keep it running with current version?

Our deployment configuration files are mirrored in this gist

Targeted server stack

This is the runner that is called by init.

The file is located at the root of the project checkout as service.sh.

#!/bin/bash

#
# Annotator Upstart script (runner)
#
# file: /srv/webplatform/h/service.sh
# Gist: https://gist.github.com/WebPlatformDocs/1ba5b980b52303b62acf
#
set -e
LOGFILE=/var/log/webplatform/hypothesis.log
LOGDIR=$(dirname $LOGFILE)
cd /srv/webplatform/h
. bin/activate
test -d $LOGDIR || mkdir -p $LOGDIR
exec bin/gunicorn --paster h.ini --log-config h.ini

Annotator Upstart script

Works with Ubuntu 12.04 + and is located at /etc/init/hypothesis.conf

#
# Annotator Upstart script
#
# file: /etc/init/hypothesis.conf
# Gist: https://gist.github.com/WebPlatformDocs/1ba5b980b52303b62acf
#
# Thanks to:
# - https://lukedrummond.net/2014/02/django-with-prefix-nginxgunicorndjango/
# - http://albertoconnor.ca/blog/2011/Sep/15/hosting-django-under-different-locations
#
description "Hypothesis server"

start on (net-device-up
          and local-filesystems
          and runlevel [2345])
stop on runlevel [!2345]

respawn
setuid renoirb
setgid deployment

script
   cd /srv/webplatform/h
   exec ./service.sh >> /var/log/webplatform/hypothesis.log 2>&1
end script

h.ini

Is the basic production.ini file with our own configs such as:

[app:main]
use: egg:h

# Hex characters in this format (not the real secret)
api.secret: ffffffff-aaaa-3333-4444-111111111111

#16 long Hex characters 
auth.wpd.client_id: 1111111111111111
#64 long Hex characters (not a real secret)
auth.wpd.client_secret: 24f5ae0631a31a27d67ac20a6f9722fcd87271d729f0c9f531d7bc4a89db3fb

[server:main]
use: egg:gunicorn
worker_class: gevent
host: 127.0.0.1
port: 5000
tilgovi commented 9 years ago

See the README and the .ini files in this repo. auth.wdp has changed to webplatform