Jump to content

Snuggle

From Wikitech

Snuggle is a workflow tool for helping Wikipedian mentors find goodfaith newcomers to support in Wikipedia.

User documention

w:en:WP:Snuggle

Code

github.com/halfak/snuggle

Development

TODO

Deployment

TODO

Orchestration

Start a medium VM with the lvm role for mounting at /srv. Then run these commands:

# Create directories in /srv
sudo mkdir /srv/snuggle/
sudo chown www-data:www-data /srv/snuggle/
sudo mkdir /srv/log
sudo mkdir /srv/log/snuggle
sudo chown www-data:www-data /srv/log/snuggle

# Install debian packages and initialize virtualenv
sudo apt-get install virtualenv build-essential python-dev python-numpy python-scipy libmysqlclient-dev uwsgi-plugin-python mongodb
sudo -u www-data virtualenv -p $(which python2.7) /srv/snuggle/venv --system-site-packages

# Clone repository
sudo -u www-data git clone https://github.com/halfak/snuggle snuggle/deploy
sudo -u www-data /srv/snuggle/venv/bin/pip install -r /srv/snuggle/deploy/requirements.txt

# Write out uwsgi configuration
sudo bash -c 'echo "[uwsgi]
chdir=/srv/snuggle/deploy
die-on-term=true
http-socket=0.0.0.0:8080
logformat=[pid: %(pid)] %(addr) (%(user)) {%(vars) vars in %(pktsize) bytes} [%(ctime)] %(method) %(uri) => generated %(rsize) bytes in %(m$
logger=file:/srv/log/snuggle/main.log
master=true
max-requests=200
memory-report=true
need-plugins=python
plugins=python, logfile
processes=32
venv=/srv/snuggle/venv
wsgi-file=/srv/snuggle/deploy/snuggle-en.wmflabs.wsgi" > /etc/uwsgi/apps-available/55-snuggle.ini'

sudo ln -s /etc/uwsgi/apps-available/55-snuggle.ini /etc/uwsgi/apps-enabled/55-snuggle.ini

# Set up mongodb
sudo mkdir /srv/snuggle/mongodb
sudo chown mongodb:nogroup /srv/snuggle/mongodb
sudo mkdir /srv/log/mongodb
sudo chown mongodb:nogroup /srv/log/mongodb

sudo cp /etc/mongodb.conf /etc/mongodb.backup.conf
sudo bash -c 'cat /etc/mongodb.backup.conf | grep mongodb | \
  sed "s*dbpath=/var/lib/mongodb*dbpath=/srv/snuggle/mongodb*" | \
  sed "s*logpath=/var/log/mongodb/mongodb.log*logpath=/srv/log/mongodb/mongodb.log*" > \
  /etc/mongodb.conf'

sudo service mongodb restart

sudo -u www-data mongo snuggle /srv/snuggle/deploy/docs/schema/indexes.js
sudo -u www-data mongo snuggle /srv/snuggle/deploy/docs/schema/sorting.js

# Start up the web service
sudo service uwsgi restart

# Start up the sync service.  This should probably done in a screen -- or better an init script. 
sudo -u www-data /srv/snuggle/venv/bin/python /srv/snuggle/deploy/syncd /srv/snuggle/deploy/config/snuggle-en.wmflabs.yaml /srv/snuggle/deploy/config/enwiki.mediawiki.yaml