你的位置:首页 > 信息动态 > 新闻中心
信息动态
联系我们

superset启动脚本

2021/10/17 7:29:43

superset.sh

#!/bin/bash

superset_status(){
	result=`ps -ef | awk '/gunicorn/ && !/awk/{print $2}' | wc -l` 
	if [[ $result -eq 0 ]]; then
		return 0
	else
		return 1
	fi
}
superset_start(){
	# 该段内容取自~/.bashrc,所用是进行 conda 初始化
	# >>> conda initialize >>>
	# !! Contents within this block are managed by 'conda init' !!
	__conda_setup="$('/opt/module/miniconda3/bin/conda''shell.bash' 'hook' 2> /dev/null)"
	if [ $? -eq 0 ]; then
		eval "$__conda_setup"
	else
		if [ -f"/opt/module/miniconda3/etc/profile.d/conda.sh" ]; then
		     . "/opt/module/miniconda3/etc/profile.d/conda.sh"
	else
			export PATH="/opt/module/miniconda3/bin:$PATH"
		fi
	fi
	unset __conda_setup
	# <<< conda initialize <<<
	superset_status >/dev/null 2>&1
	if [[ $? -eq 0 ]]; then
		conda activate superset ; gunicorn --workers 5 --timeout 120 --bind sc1:8787 --daemon 'superset.app:create_app()'
	else
		echo "superset 正在运行"
	fi
}
superset_stop(){
	superset_status >/dev/null 2>&1
	if [[ $? -eq 0 ]]; then
		echo "superset 未在运行"
	else
		ps -ef | awk '/gunicorn/ && !/awk/{print $2}' | xargs kill -9
	fi
}
case $1 in
	start )
		echo "启动 Superset"
		superset_start
	;;
stop )
	echo "停止 Superset"
	superset_stop
	;;
restart )
	echo "重启 Superset"
	superset_stop
	superset_start
	;;
status )
	superset_status >/dev/null 2>&1
	if [[ $? -eq 0 ]]; then
		echo "superset 未在运行"
	else
		echo "superset 正在运行"
	fi
esac