yum install supervisor -y && systemctl start supervisord.service && systemctl enable supervisord.service
编写新建配置文件/etc/supervisord.d/jupyter.ini
cat >/etc/supervisord.d/jupyter.ini <
[program:jupyter] #程序唯一名称
directory=/data/jupyter #程序路径
command=jupyter lab --no-browser --allow-root #运行程序的命令
user=root #用哪个用户启动进程,默认是root
redirect_stderr=true #把stderr重定向到stdout标准输出,默认false
stdout_logfile=/data/logs/jupyter.log #标准输出日志
stdout_logfile_maxbytes=200MB #stdout标准输出日志文件大小,日志文件大小到200M后则进行切割
autostart=true #启动后jupyter也启动
autorestart=true #程序退出后自动重启,可选值:[unexpected,true,false],默认为unexpected,表示进程意外杀死后才重启;意思为如果不是supervisord来关闭的该进程则认为不正当关闭,supervisord会再次把该进程给启动起来,只能使用该supervisorctl来进行关闭、启动、重启操作
startretries=3 #启动失败自动重试次
startsecs=10 #启动10秒后没有异常退出,就表示进程正常启动了,默认为1秒
stopwaitsecs = 60
environment=ENV=“dev”
EOF
使用 supervisorctl 命令来管理
#查看下面管理哪些任务
supervisorctl status
#启动jupyter
supervisorctl start jupyter
#停止jupyter
supervisorctl stop jupyter
#/etc/supervisord.d/jupyter.ini 文件内容有更新时使用
supervisorctl update jupyter 或者 supervisorctl reoload jupyter
#重启jupyter
supervisorctl restart jupyter