Skip to content

Instantly share code, notes, and snippets.

@druchoo
Forked from Gromph/gist:5f4db73b0f38775bc2f0
Last active August 29, 2015 14:15
Show Gist options
  • Save druchoo/9ca0bf38201cfe37d6b8 to your computer and use it in GitHub Desktop.
Save druchoo/9ca0bf38201cfe37d6b8 to your computer and use it in GitHub Desktop.
The Cabot quick start instructions are for auto installing on ubuntu using fabric, gunicorn, postgres.
I wanted to install manually on CentOS 7 running with uwsgi, nginx, mysql, and use our own mail server for
alerts instead of Amazon SES
These are my notes on how I did that.
These notes aren't a complete walkthrough, and a few steps may be missing or wrong, but I thought they might
be helpful anyways.
Setup
1. adduser www
passwd www
mkdir /var/www/
mkdir /var/www/logs/
mkdir /var/www/run/
mkdir /var/www/run/celery/
chown -R www.www /var/www/
2. download(or clone) Cabot from github: https://github.com/arachnys/cabot/archive/master.zip
3. unziped to /var/www/cabot/
4. python setup.py install
I'm not sure if this was necessary
5. yum install pip gcc python-devel openssl-devel
6. pip install setuptools --upgrade
7. copied list of required packages from setup.py to requirements.txt
replaced psycopg2 with MySQL-python
8. pip install -r requirements.txt
9. If you want to use your own smtp server instead of amazon:
nano cabot/settings.py
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = "mail.silvercrk.com"
10. cp conf/production.env.example cp conf/production.env
11. nano conf/production.env
DATABASE_URL=mysql://cabot:PASSWORD@db.lan2/Cabot
ADMIN_EMAIL=admin@example.com
GRAPHITE_API=http://graphite.lan2/
GRAPHITE_USER=cabot
GRAPHITE_PASS=PASSWORD
WWW_HTTP_HOST=monitor.lan2
12. Install node:
yum install gcc-c++
wget http://nodejs.org/dist/v0.10.33/node-v0.10.33.tar.gz
./configure
make
make install
npm install -g coffee-script less@1.3 --registry http://registry.npmjs.org/
13. sh -ac ' . ./conf/production.env; python manage.py syncdb'
14. sh -ac ' . ./conf/production.env; python manage.py migrate'
15. sh -ac ' . ./conf/production.env; python manage.py collectstatic --noinput'
16. sh -ac ' . ./conf/production.env; python manage.py compress'
17. Setup uwsgi
pip install uwsgi
nano /etc/systemd/system/uwsgi.service
[Unit]
Description=uWSGI Emperor
After=syslog.target
[Service]
ExecStart=/bin/uwsgi --ini /etc/uwsgi/emperor.ini
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=main
[Install]
WantedBy=multi-user.target
nano /etc/uwsgi/vassals/cabot.ini
[uwsgi]
chdir=/var/www/cabot
module=cabot.wsgi
master=True
vacuum=True
max-requests=50000
socket=localhost:5000
processes=10
logto=/var/www/logs/cabot_uwsgi.log
for-readline = /var/www/cabot/conf/production.env
env = %(_)
endfor =
systemctl start uwsgi
systemctl enable uwsgi
18. Setup Nginx
Install official Nginx rpm from repo: http://wiki.nginx.org/Install
nano /etc/nginx/conf.d/cabot.conf
upstream django {
server 127.0.0.1:5000;
}
server {
listen 10.1.0.74:80;
server_name monitor.lan2;
access_log /var/www/logs/cabot.access.log;
error_log /var/www/logs/cabot.error.log;
location / {
uwsgi_pass django;
include uwsgi_params;
}
location /static/ {
alias /var/www/cabot/static/;
}
}
systemctl start nginx
systemctl enable nginx
19. Setup systemd file to run celery workers
nano /etc/systemd/system/cabot-worker.service
# Copied and modified from https://github.com/celery/celery/blob/3.1/extra/systemd/celery.service
[Unit]
Description=CabotCelery workers
After=network.target
[Service]
Type=forking
User=www
Group=www
WorkingDirectory=/var/www/cabot/
EnvironmentFile=/var/www/cabot/conf/production.env
ExecStart=/bin/celery multi start worker \
-A cabot --pidfile=/var/www/run/celery/%n.pid \
--logfile=/var/www/logs/celery_%n.log --loglevel="INFO" \
-B
ExecStop=/bin/celery multi stopwait worker \
--pidfile=/var/run/celery/%n.pid
ExecReload=/bin/celery multi restart worker \
-A cabot --pidfile=/var/www/run/celery/%n.pid \
--logfile=/var/www/logs/celery_%n.log --loglevel="INFO"
[Install]
WantedBy=multi-user.target
systemctl start cabot-worker
systemctl enable cabot-worker
20. Install redis
Install epel: rpm -Uvh http://mirror.symnds.com/distributions/fedora-epel/7/x86_64/e/epel-release-7-2.noarch.rpm
yum install redis
systemctl start redis
systemctl enable redis
21. goto http://monitor.lan2 and see if everything is successfully running
Run cabot without uwsgi and nginx for testing:
sh -ac ' . ./conf/production.env; python manage.py runserver'
To run uwsgi server for testing:
sh -ac ' . ./conf/production.env; uwsgi --socket localhost:5000 --module cabot.wsgi --chmod-socket=664'
Manually run celery workers:
sh -ac '. ./conf/production.env; celery worker -B -A cabot --loglevel=INFO --concurrency=16 -Ofair'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment