需要帮助在Ubuntu中使用Ups运行Python app as service

2024-05-29 02:41:37 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经用Python编写了一个日志应用程序,打算在启动时启动,但是我无法用Ubuntu's Upstart init daemon启动该应用程序。当使用sudo/usr/local/greenlog/main.pyw从终端运行时,应用程序工作正常。以下是我为新贵工作所做的努力:

/etc/init/greeenlog.conf

# greeenlog

description     "I log stuff."

start on startup
stop on shutdown

script
    exec /usr/local/greeenlog/main.pyw
end script

我的应用程序启动一个子线程,以防这很重要。我试过用expect fork节来完成这项工作,结果没有任何变化。我还尝试过使用sudo和不使用脚本语句(只是一个单独的exec语句)来实现这一点。在所有情况下,启动后,运行状态greenlog返回greenlog stop/waiting并运行启动greenlog返回:

start: Rejected send message, 1 matched rules; type="method_call", sender=":1.61" (uid=1000 pid=2496 comm="start) interface="com.ubuntu.Upstart0_6.Job" member="Start" error name="(unset)" requested_reply=0 destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init"))

有人知道我做错了什么吗?我很感激你能给我任何帮助。谢谢。


Tags: 应用程序initmainonusrlocalsudoscript

热门问题