环境
- centos 6.5
- anaconda 3
- python 3.6
- superset 0.30
- gunicorn 19.8
- gevent 1.4
安装gunicore
$ pip install gunicorn
$ pip install gevent
//# 建立用户组
$ groupadd superset
$useradd -g superset superset -s /bin/nologin
//# 建立日志目录
$ mkdir /var/log/superset/
$ chown superset:superset /var/log/superset/
需要家目录,superset要在家目录下新建.superset目录
服务启动脚本
#! /bin/sh
# chkconfig: 2345 55 25
# Description: Startup script for superset webserver on Debian. Place in /etc/init.d
# For CentOS/Redhat run: 'chkconfig --add superset'
### BEGIN INIT INFO
# Provides: superset
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the superset server
# Description: starts superset using start-stop-daemon
### END INIT INFO
# Author: chenzl
PYTHON='/usr/local/anaconda3/envs/py3.6/bin/python'
GUNICORN='/usr/local/anaconda3/envs/py3.6/bin/gunicorn'
if [ ! -f "$GUNICORN" ];then
echo "need install the gunicorn"
exit
fi
ACCESS_LOG='/var/log/superset/acecess.log'
ERROR_LOG='/var/log/superset/error.log'
PORT='80'
PS_SUPERSET=`ps aux | grep "$GUNICORN" | grep -v 'grep' | awk '{print $2}'`
case "$1" in
start)
if [ -n "$PS_SUPERSET" ] ;then
echo "superset already running."
echo "$PS_SUPERSET"
exit 1
else
echo -n "Starting superset... "
echo
$PYTHON $GUNICORN -w 10 -k gevent --timeout 120 -b 0.0.0.0:$PORT --limit-request-line 0 --limit-request-field_size 0 --access-logfile $ACCESS_LOG --error-logfile $ERROR_LOG --user superset --group superset --daemon superset:app
if [ "$?" != 0 ] ; then
echo " Faild"
exit 1
else
echo " success"
fi
fi
;;
stop)
if [ -n "$PS_SUPERSET" ] ;then
echo -n "Stoping superset... "
for pid in "$PS_SUPERSET";do
kill $pid
done
if [ "$?" != 0 ] ; then
echo " Faild"
exit 1
else
echo " Success"
fi
else
echo -n "the superset dont exists"
echo
exit
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
加入到/etc/init.d/
启动服务
//# 修改权限
$ chmod 755 superset
//# 启动,停止服务
$ service superset start
$ service superset stop