惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
T
Threatpost
Latest news
Latest news
N
News | PayPal Newsroom
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Help Net Security
Help Net Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
AI
AI
Simon Willison's Weblog
Simon Willison's Weblog
TaoSecurity Blog
TaoSecurity Blog
The Last Watchdog
The Last Watchdog
L
LINUX DO - 热门话题
Google DeepMind News
Google DeepMind News
T
Threat Research - Cisco Blogs
O
OpenAI News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
The Exploit Database - CXSecurity.com
NISL@THU
NISL@THU
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
Securelist
小众软件
小众软件
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Martin Fowler
Martin Fowler
S
SegmentFault 最新的问题
Cisco Talos Blog
Cisco Talos Blog
云风的 BLOG
云风的 BLOG
AWS News Blog
AWS News Blog
GbyAI
GbyAI
N
News and Events Feed by Topic
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
美团技术团队
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
S
Schneier on Security
博客园 - 聂微东
V2EX - 技术
V2EX - 技术
T
Troy Hunt's Blog
SecWiki News
SecWiki News
S
Secure Thoughts
B
Blog RSS Feed
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
腾讯CDC
H
Heimdal Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Privacy International News Feed

Jupyter

SSL 认证莫名其妙报错了,需要引起警惕吗? - V2EX 这是什么 jupyter 插件,感觉挺酷 - V2EX 现在人工智能专业这么火,大家 jupyter 常用的一些插件和功能是啥? - V2EX pycharm 的里的 jupyternotebook 能断点调试吗? - V2EX Jupyter Notebook 到底是用来干啥的? - V2EX pycharm 里连接远程 jupyter,自动补全怎么搞? - V2EX 单元格如何取消关联 - V2EX jupyter-notebook 内置环境变量问题 - V2EX Jupyter 里有什么插件 / Kernel 可以实现类似 ob-http 的功能 - V2EX 如何计算重复率统计? - V2EX 如何在内网环境从 Windows SSH 访问 Linux 服务器 - V2EX anaconda3 环境下,在 cmd 输入"jupyter lab"显示"Exception: Jupyter command `jupyter-lab` not found." - V2EX jupyter 中通过 ctypes 调用 printf()时,不显示 printf()打印内容 - V2EX jupyter-nbconvert.exe --generate-config 报错 UnicodeEncodeError: 'gbk' - V2EX jupyter 转 markdown 要是能内嵌图片就好了 - V2EX JupyterLab 插件功能小贴士 - V2EX Jupyter 的输出窗口可以同时动态刷新两种图吗? - V2EX 最近整理了一些 Jupyter book 文档 - V2EX jupyter 怎么读 - V2EX 使用 Jupyter notebook 生成柱状图失败,问题出在哪?? - V2EX 求助, Jupyter 已经启动,但是网页无法显示 - V2EX 用 Jupyter 写非 Python 体验如何? - V2EX 写了一些 Jupyter notebook 的扩展插件 - V2EX Jupyter 上的 Lua 与 torch7 - V2EX
Supervisor 无法停止 Jupyter Notebook - V2EX
bwangel · 2016-03-31 · via Jupyter

最近在玩 Jupyter Notebook ,想用这个来写学习 Python 的笔记!打算通过 Supervisor 来管理 Jupyter Notebook ,再加上一个 Nginx 进行反向代理(略显无聊,纯粹为了好玩)。

结果现在卡在 Supervisor 管理 Jupyter Notebook 上了。废话少说,贴代码:

相关配置

Supervisor 的配置

# 这分别是 supervisord 和 Jupyter 程序的配置
[supervisord]
logfile=/home/supervisord/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB        ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10           ; (num of main logfile rotation backups;default 10)
loglevel=info                ; (log level;default info; others: debug,warn,trace)
pidfile=/home/supervisord/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false               ; (start in foreground if true;default false)
minfds=1024                  ; (min. avail startup file descriptors;default 1024)
minprocs=200                 ; (min. avail process descriptors;default 200)
;umask=022                   ; (process file creation umask;default 022)
;user=chrism                 ; (default is current user, required if root)
;identifier=supervisor       ; (supervisord identifier, default is 'supervisor')
;directory=/tmp              ; (default is not to cd during start)
;nocleanup=true              ; (don't clean up tempfiles at start;default false)
;childlogdir=/tmp            ; ('AUTO' child log dir, default $TEMP)
;environment=KEY="value"     ; (key value pairs to add to environment)
;strip_ansi=false            ; (strip ansi escape codes in logs; def. false)

[program:jupyter-notebook]
user=xff
command=bash /home/xff/bin/start_notebook.sh
process_name=ipython_notebook
environment=HOME="/home/xff/"
numprocs=1
numprocs_start=3
direcotory=/home/xff/Documents
stdout_logfile=/home/supervisord/jupyter-notebook.log        ; stdout log path, NONE for none; default AUTO
stdout_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
stdout_logfile_backups=10     ; # of stdout logfile backups (default 10)
stdout_capture_maxbytes=1MB   ; number of bytes in 'capturemode' (default 0)
stdout_events_enabled=false   ; emit events on stdout writes (default false)
stderr_logfile=/home/supervisord/jupyter-notebook.err        ; stderr log path, NONE for none; default AUTO
stderr_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
stderr_logfile_backups=10     ; # of stderr logfile backups (default 10)
stderr_capture_maxbytes=1MB   ; number of bytes in 'capturemode' (default 0)
stderr_events_enabled=false   ; emit events on stderr writes (default false)
stopsignal=KILL
stopwaitsecs=5
;autostart=true
;autorestart=true

Jupyter Notebook 的启动脚本

# /home/xff/bin/start_notebook.sh 文件, Jupyter Notebook 的启动脚本
#!/bin/bash
NOTEBOOK_CMD="/home/xff/.virtualenvs/jupyter/bin/jupyter-notebook --config=/home/xff/.jupyter/jupyter_notebook_config.py"
echo $NOTEBOOK_CMD >> /home/xff/log
$NOTEBOOK_CMD

错误情况

通过 supervisorctl 启动 Jupyter Notebook 后,进程树是这样的:

root       5004  0.0  1.3 207632 13264 ?        Ss   16:51   0:00 /usr/local/Python-2.7.11/bin/python2.7 /usr/local/Python-2.7.11/bin/supervisord -c /etc/supervisord.conf --user=root
xff        5142  0.1  0.1 106100  1220 ?        S    17:00   0:00  \_ bash /home/xff/bin/start_notebook.sh
xff        5143  7.8  3.4 286876 35104 ?        S    17:00   0:00      \_ /home/xff/.virtualenvs/jupyter/bin/python2.7 /home/xff/.virtualenvs/jupyter/bin/jupyter-notebook --config=/home/xff/.jupyter/jupyter_notebook_config.py

在 supervisorctl 上停止 Jupyter Notebook 之后,进程树就变成这样了,

root       3196  0.0  0.1  42708  1836 ?        Ss   15:33   0:00 nginx: master process nginx
www        3728  0.0  0.2  43124  2196 ?        S    16:03   0:02  \_ nginx: worker process
www        3729  0.0  0.2  43124  2196 ?        S    16:03   0:01  \_ nginx: worker process
root       5004  0.0  1.3 207784 13336 ?        Ss   16:51   0:00 /usr/local/Python-2.7.11/bin/python2.7 /usr/local/Python-2.7.11/bin/supervisord -c /etc/supervisord.conf --user=root
xff        5143  0.2  3.4 286876 35104 ?        S    17:00   0:00 /home/xff/.virtualenvs/jupyter/bin/python2.7 /home/xff/.virtualenvs/jupyter/bin/jupyter-notebook --config=/home/xff/.jupyter/jupyter_notebook_config.py

很明显, Jupyter Notebook 的进程并没有被停止,它变成了孤儿进程,被 Init 收养了。

我开始以为是 supervisor 发送的停止信号不对,后来吧 supervisor 配置文件中,程序的停止信号stopsignal变成了kill还是不行,但如果我在命令行中执行

# Jupyter Notebook 默认监听的是 8888 端口
kill -9 `lsof -ti:8888`

是可以的!

万能的 V 友们,给点提示吧,这是什么原因啊,从哪里入手解决呀!