superset 以gunicorn启动,并加为系统服务

环境
  • 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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值