How to install Cabot on CentOS

2018-11-14 17:56:36

Cabot环境搭建

初始化mysql数据库

1
2
3
$ mysql -u root -p -e "CREATE USER cabot@localhost IDENTIFIED BY 'cabot'";
$ mysql -u root -p -e "CREATE DATABASE cabot";
$ mysql -u root -p -e "GRANT ALL PRIVILEGES ON \`cabot\`.* TO \`cabot\`@localhost";

下载cabot

1
git clone https://github.com/arachnys/cabot.git

安装依赖软件

1
2
3
4
5
6
7
8
9
10
11
12
$ sudo yum install ruby
$ sudo gem install foreman
$ sudo pip install fabric
$ sudo yum install python-devel
$ sudo yum install openldap-devel
$ sudo pip install -r requirements.txt
$ sudo pip install -r requirements-plugins.txt
$ sudo pip install -r requirements-dev.txt
$ sudo pip install MySQL-python
$ sudo yum install nodejs
$ sudo npm install -g less
$ sudo npm install -g coffee-script

修改配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
$ cp production.env.example production.env
$ vi production.env
DEBUG=t
DATABASE_URL=mysql://cabot:cabot@localhost:3306/cabot
DJANGO_SETTINGS_MODULE=cabot.settings
LOG_FILE=log
PORT=5008

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
TIME_ZONE=Asia/Shanghai

# Django settings
CELERY_BROKER_URL=redis://localhost:6379/1
DJANGO_SECRET_KEY=2FL6ORhHwr5eX34pP9mMugnIOd3jzVuT45f7w430Mt5PnEwbcJgma0q8zUXNZ68A

# Hostname of your Graphite server instance
GRAPHITE_API=http://*.*.*.*:12346/
GRAPHITE_USER=username
GRAPHITE_PASS=password

修改启动文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$ vi .foreman

# vi: set ft=yaml :
procfile: Procfile
env: conf/production.env

$ vi gunicorn.conf

# -*- mode: python -*-
# vi: set ft=python :
import os
bind = '0.0.0.0:%s' % os.environ['PORT']
workers = 3

$ vi Procfile
web: gunicorn cabot.wsgi:application --config gunicorn.conf
celery: celery worker -B -A cabot --loglevel=INFO --concurrency=16 -Ofair
beat: celery beat -A cabot --loglevel=INFO

初始化数据库

1
$ sh setup_dev.sh

启动web程序

1
$ foreman start web

启动celery

1
foreman start celery

登录管理页面(第一次登录需要设置管理员账号)

使用supervisor管理Cabot,Celery进程

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$ sudo vi /etc/supervisord.d/cabot.conf

[program:web]
command=foreman start web
autorstart=true
autorestart=true
redirect_stderr=true
stopsignal=TERM
stdout_logfile=/var/log/web.log
directory=/opt/cabot

[program:celery]
command=foreman start celery
autorstart=true
autorestart=true
redirect_stderr=true
stopsignal=TERM
stdout_logfile=/var/log/celery.log
directory=/opt/cabot

使用supervisor管理程序

1
sudo supervisorctl reload

遇到的错误

1
2
3
4
5
6
7
8
9
10
11
1. "Missing staticfiles manifest entry for '%s'" % clean_name
#解决方法
python manage.py collectstatic

2. CommandError: An error occurred during rendering /usr/local/whistle/webapps/cabot/cabot/templates/cabotapp/statuscheck_report.html:
/bin/sh: lessc: command not found
#解决方法
pip install nodeenv
nodeenv nodeenv
source nodeenv/bin/activate
npm install -g less

ref
Cabot Alert Mysql环境搭建
Cannot run Biostars out of the box: “lessc: command not found”
ValueError: Missing staticfiles manifest entry for ‘favicon.ico’


您的鼓励是我写作最大的动力

俗话说,投资效率是最好的投资。 如果您感觉我的文章质量不错,读后收获很大,预计能为您提高 10% 的工作效率,不妨小额捐助我一下,让我有动力继续写出更多好文章。