-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the aws-documentation wiki!
User: ec2-user
~/bin/do_mirror
User: inphosite
Python Environment: Miniconda 2
Additional yum
packages: tmux nginx redhat-lsb-core
Additional conda
packages (for user inphosite
): gunicorn mysql-python docutils sphinx nltk
Rough outline of install from scratch:
sudo mkdir /var/inpho
sudo chown inphosite:inpho /var/inpho
sudo su inphosite
cd /tmp
wget https://repo.continuum.io/miniconda/Miniconda2-4.3.30-Linux-x86_64.sh
bash Miniconda2-4.3.30-Linux-x86_64.sh
conda install mysql-python sphinx docutils sphinx nltk
python -m nltk.downloader all # TODO: get minimal spanning set of nltk packages, use global NLTK_DATA directory.
cd /var/inpho
git clone https://github.com/inpho/inpho.git
cd inpho
python setup.py develop
cd ..
git clone https://github.com/inpho/inphosite.git
cd inphosite
python setup.py develop
Configure database on Amazon RDS. I migrated us from MySQL to MariaDB, which is the pure open-source fork of MySQL.
Security policy has to allow access on port 3306 to your machine.
I uploaded database from my own machine using a database connetion:
mysql -h inpho.c1qnbhebkxsc.us-east-2.rds.amazonaws.com -P 3306 -u inpho -p seponto < /var/inpho/backup/sql/20171207.sql
The web server for inphosite is gunicorn + nginx. Gunicorn is a WSGI-compliant, Python-based server optimized for high throughput. nginx is an alternative to Apache which was optimized to maximize the number of concurrent connections through an event loop. It also has simpler path routing for static resources on shared hosts with dynamic resources. The memory model is superior as it does not embed the WSGI process in the worker processes.
Sample configuration:
sudo yum install nginx
sudo su inphosite
conda install gunicorn
Test server:
gunicorn --paste production.ini -b :5000 --chdir /var/inpho/inphosite
If the server is successfully started and you can test using port 5000, then we can deploy a service.
First, create /etc/init.d/inphosite
:
#! /bin/bash
### BEGIN INIT INFO
# Provides: inphosite
# Required-Start: nginx
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: The main pylons process
# Description: The gunicorn process that receives HTTP requests
# from nginx
#
### END INIT INFO
#
# Author: Jaimie Murdock <[email protected]>
#
APPNAME=inphosite
USER=inphosite
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/home/inphosite/miniconda2/bin
CHROOT=/var/inpho/inphosite
CONFIG=production.ini
DAEMON=gunicorn
#BIND=0.0.0.0:5000
BIND=unix:/var/inpho/inphosite.sock
PIDFILE=/var/run/gunicorn.pid
LOGFILE=/var/log/$DAEMON.log
WORKERS=2
. /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 --paste $CONFIG --chdir $CHROOT
#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 inphosite start
.
Check the status with sudo service inphosite status
Stop with sudo service inphosite stop
It may be possible to enable these services without sudo privileges, but I haven't looked into that yet for init.d
system configs. TODO: Enable service permissions for all users in inphosite
group.
These commands will be run as the root
account.
sudo yum install nginx
sudo mkdir /etc/nginx/sites-available
sudo touch /etc/nginx/sites-available/inphosite.conf
sudo ln -s /etc/nginx/sites-available/inphosite.conf /etc/nginx/sites-enabled/inphosite.conf
Edit the /etc/nginx/nginx.conf
to add sites-enabled
directory:
...
http {
...
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*.conf;
...
}
Edit /etc/nginx/sites-available/inphosite.conf
:
server {
listen 80;
server_name inphoproject.org www.inphoproject.org;
location = /favicon.ico { access_log off; log_not_found off; }
location / {
include proxy_params;
proxy_pass http://unix:/var/inpho/inphosite.sock;
}
}
User: hypershelf
Python Environment: Miniconda 3
- master
- mining
- sep-topics
- hypershelf