【发布时间】:2019-04-19 09:49:45
【问题描述】:
Ubuntu 14.04
我有一份简单的新贵工作test.conf:
root@ubuntutest:~# cat /etc/init/test.conf
expect fork
script
/root/test.py
end script
和简单的python脚本/root/test.py:
root@ubuntutest:~# cat /root/test.py
#!/usr/bin/python
import time
print("Hello, World")
time.sleep(30)
print("Goodbye")
我开始测试工作,确保 upstart 跟踪正确的 PID,等待脚本终止,但 upstart 不会停止跟踪不存在的 PID。所以 upstart 总是显示作业正在运行(而实际上它不是)
root@ubuntutest:~# initctl status test
test stop/waiting
root@ubuntutest:~# initctl start test
test start/running, process 1859
root@ubuntutest:~# ps aux | grep 1859
root 1859 0.2 0.7 29832 7188 ? S 14:43 0:00 /usr/bin/python /root/test.py
root 1862 0.0 0.2 11760 2156 pts/0 S+ 14:43 0:00 grep --color=auto 1859
root@ubuntutest:~# ps aux | grep 1859
root 1864 0.0 0.2 11760 2224 pts/0 S+ 14:43 0:00 grep --color=auto 1859
root@ubuntutest:~# initctl status test
test start/running, process 1859
如果我从测试作业中删除 expect fork,那么一切正常(除了新贵轨道 sh 而不是 python) - 我想了解我的代码有什么问题?
如果我使用 bash 脚本而不是 python,也会发生同样的情况:
#!/bin/bash
sleep 30
【问题讨论】:
标签: ubuntu-14.04 upstart