Skip to content

Commit

Permalink
added setup script
Browse files Browse the repository at this point in the history
  • Loading branch information
frnsys committed Jul 18, 2014
1 parent b88cb7d commit d095bed
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 0 deletions.
15 changes: 15 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
# CLONES FOR EVERYBODY

## Setup

This has been tested with Ubuntu 14.04 on a Digital Ocean server.

Run:
```bash
$ ./setup/setup.sh
```

If you're having issues:
* nginx logs: `/var/log/nginx/`
* supervisor logs: `/var/log/supervisor/`
* celery logs: `/var/log/celery/`
* application logs: `/var/log/ustwo.log`
24 changes: 24 additions & 0 deletions setup/nginx/ustwo.hyper.pub.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
server {
listen 80;
server_name ustwo.hyper.pub;

location /static {
alias /srv/ustwo/app/static;
}

location / {
include uwsgi_params;
uwsgi_pass unix:/tmp/uwsgi.sock;
uwsgi_param UWSGI_PYHOME /env/ustwo;
uwsgi_param UWSGI_CHDIR /srv/ustwo;
uwsgi_param UWSGI_MODULE application;
uwsgi_param UWSGI_CALLABLE app;
}

error_page 404 /404.html;

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
46 changes: 46 additions & 0 deletions setup/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Get ready
sudo apt-get update && sudo apt-get upgrade

# Packages
sudo apt-get install nginx python3-pip git uwsgi supervisor uwsgi-plugin-python uwsgi-plugin-python3 ruby npm rabbitmq-server

# NPM/Bower
sudo ln -s /usr/bin/nodejs /usr/bin/node
sudo npm install -g bower

# MongoDB
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
echo "deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen" | sudo tee -a /etc/apt/sources.list
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install mongodb-10gen
sudo service mongodb start

# Virtualenv
pip3 install virtualenv
virtualenv -p python3 /env/ustwo --no-site-packages

# Sass
gem install sass

# Setup app
cd /srv
git clone https://github.com/publicscience/ustwo.git
cd /srv/ustwo
source /env/ustwo/bin/activate
pip install -r requirements.txt
bower install

# Celery
sudo mkdir /var/log/celery
sudo adduser --system celery --group

# Supervisor
sudo cp /srv/ustwo/setup/supervisor/*.conf /etc/supervisor/conf.d/

# Nginx
sudo sed -i '' 's/# server_names_hash_bucket_size/server_names_hash_bucket_size/g' /etc/nginx/nginx.conf
sudo cp /srv/ustwo/setup/nginx/*.conf /etc/nginx/conf.d/

# Restart
sudo service nginx restart
sudo service supervisor restart
26 changes: 26 additions & 0 deletions setup/supervisor/celery.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[program:celery]
; Set full path to celery program if using virtualenv
command=/env/ustwo/bin/celery worker --loglevel=INFO --config=config

directory=/srv/ustwo
stdout_logfile=/var/log/celery/worker.log
stderr_logfile=/var/log/celery/worker.log
autostart=true
autorestart=true
startsecs=10

user=celery
group=celery

; Need to wait for currently executing tasks to finish at shutdown.
; Increase this if you have very long running tasks.
stopwaitsecs = 600

; When resorting to send SIGKILL to the program to terminate it
; send SIGKILL to its whole process group instead,
; taking care of its children as well.
killasgroup=true

; if rabbitmq is supervised, set its priority higher
; so it starts first
priority=998
8 changes: 8 additions & 0 deletions setup/supervisor/ustwo.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[program:ustwo]
command=/usr/bin/uwsgi --plugin python3 -s /tmp/uwsgi.sock -w application:app -H /env/ustwo --chmod-socket=666
directory=/srv/ustwo
autostart=true
autorestart=true
stdout_logfile=/var/log/ustwo.log
redirect_stderr=true
stopsignal=QUIT

0 comments on commit d095bed

Please sign in to comment.