如何在启动时启动ipython笔记本服务器作为守护进程

时间:2013-01-12 20:39:52

标签: python ipython

我喜欢ipython,尤其是笔记本电脑功能。我目前正在使用笔记本进程运行一个屏幕会话。我如何将ipython的笔记本引擎/网络服务器添加到我的系统(CentOS5)启动程序中?

3 个答案:

答案 0 :(得分:11)

vi /usr/lib/systemd/system/ipython-notebook.service
#put the following in there.
-----------------8<------------------
    [Unit]
    Description=IPython notebook

    [Service]
    Type=simple
    PIDFile=/var/run/ipython-notebook.pid
    ExecStart=/usr/bin/ipython notebook --no-browser
    User=ipynb
    Group=ipynb
    WorkingDirectory=/home/ipynb/notebooks

    [Install]
    WantedBy=multi-user.target
-----------------8<------------------

# useradd ipynb
# su - ipynb # go there create notebooks dir
# systemctl daemon-reload
# systemctl enable ipython-notebook
# systemctl start ipython-notebook

credits

答案 1 :(得分:6)

也许会这样:

cd /path/to/notebookdir && ipython notebook --no-browser &
/etc/rc.d/rc.local中的

?这是'简单'的方式,我认为如果它只是你的个人机器,但如果它是一个'真正的'服务器你应该做一个完整的Sys V-init事情;有关详情,请参阅this question

答案 2 :(得分:3)

我假设您不想以root身份运行该程序。这是我的修改版本,其运行时为<username>(在/etc/rc.local行之前放入exit 0):

su <username> -c "/usr/bin/ipython notebook --no-browser --profile <profilename> &"

您可以检查以确保您的ipython位于which ipython的路径上。虽然你可能只是没有完整的路径而逃脱。

相关问题