-
Notifications
You must be signed in to change notification settings - Fork 0
Topic Bars for inphosite
Jaimie Murdock edited this page Dec 18, 2017
·
15 revisions
Topic bars are configured as a server socket on the same EC2 instance as inphosite
. This socket is then bound to the /topics/sep/
location on nginx.
Add to instance start-up script
#!/bin/bash
useradd inpho
useradd sep
useradd topics
usermod -g inpho topics
usermod -g inpho sep
yum install -y gcc gcc-c++ make redhat-lsb-core
yum install -y tmux htop
mkdir /var/sep
chown sep:inpho /var/sep
mkdir /var/inpho
chown inpho:inpho /var/inpho
chmod 775 /var/inpho
echo "fs-2c877655.efs.us-east-2.amazonaws.com:/\t/var/sep\tnfs4\tnfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 0 0" >> /etc/fstab
mount -a
cd /tmp
wget https://repo.continuum.io/miniconda/Miniconda2-4.3.30-Linux-x86_64.sh
bash /tmp/Miniconda2-4.3.30-Linux-x86_64.sh -b
echo 'export PATH="/home/$USER/miniconda2/bin/:$PATH"' >> ~/.bashrc
. ~/.bashrc
conda install -y pip numpy scipy scikit-learn nltk unidecode matplotlib cython pyyaml networkx wget decorator chardet pandas
pip install topicexplorer
TODO: update conda install
to use an environment.yml
file
sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=2048
sudo /sbin/mkswap /var/swap.1
sudo /sbin/swapon /var/swap.1
sudo chmod 600 /var/swap.1
https://stackoverflow.com/a/20890162
pip install gunicorn gevent czipfile
Create a file sep_topics.py
:
from argparse import ArgumentParser
import topicexplorer.server
parser = ArgumentParser()
topicexplorer.server.populate_parser(parser)
args = parser.parse_args(['fall2016.ini', '--no-browser'])
app = topicexplorer.server.create_app(args)
Test server with: gunicorn -k gevent -w 3 --bind 0.0.0.0:8000 sep_topics:app
First, create /etc/init.d/topics:
#! /bin/bash
### BEGIN INIT INFO
# Provides: topics
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: The main topic explorer process
# Description: The gunicorn process that receives HTTP requests
# from nginx
#
### END INIT INFO
#
# Author: Jaimie Murdock <[email protected]>
#
APPNAME=topics
USER=topics
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/home/topics/miniconda2/bin
CHROOT=/home/topics/topics
DAEMON=gunicorn
BIND=0.0.0.0:8000
PIDFILE=/var/run/gunicorn.pid
LOGFILE=/var/log/$DAEMON.log
WORKERS=3
. /lib/lsb/init-functions
if [ -e "/etc/default/$APPNAME" ]
then
. /etc/default/$APPNAME
fi
case "$1" in
start)
#log_daemon_msg "Starting deferred execution scheduler" "$APPNAME"
cd $CHROOT
$DAEMON --daemon --bind=$BIND --pid=$PIDFILE --workers=$WORKERS --user=$USER --log-file=$LOGFILE --chdir $CHROOT -k gevent sep_topics:app
#log_end_msg $?
;;
stop)
#log_daemon_msg "Stopping deferred execution scheduler" "APPNAME"
killproc -p $PIDFILE $DAEMON
#log_end_msg $?
;;
force-reload|restart)
$0 stop
$0 start
;;
status)
#status_of_proc -p $PIDFILE $DAEMON && exit 0 || exit $?
killall -0 $DAEMON && echo "Running $APPNAME" && exit 0 || exit $?
;;
*)
echo "Usage: /etc/init.d/$APPNAME {start|stop|restart|force-reload|status}"
exit 1
;;
esac
exit 0
Then run sudo service topics start
.
Check the status with `sudo service topics status
Stop with sudo service topics stop
chkconfig --add inphosite
chkconfig inphosite on
- master
- mining
- sep-topics
- hypershelf