在Ubuntu systemd服务中运行python -m

时间:2019-10-09 01:10:41

标签: python systemd

有:

我需要将python模块作为systemd服务运行。

命令是cd / home / bitnami / abc / && python -m abc.abc。

在/ etc / systemd / system中,abc.service是这样的:

[Unit]<br>
Description=xxxx<br>
After=syslog.target<br>
After=network.target[Service]<br>
User=ubuntu<br>
Type=simple<br>

[Service]<br>
Type=simple<br>
ExecStart=/usr/bin/python -m abc.abc<br>
WorkingDirectory=/home/abc/abc<br>
Restart=always<br>
StandardOutput=syslog<br>
StandardError=syslog<br>
SyslogIdentifier=helloworld<br>

[Install]<br>
WantedBy=multi-user.target<br>
<br>
when I check status
I got this
<br>
● abc.service - abc Push Notification<br>
   Loaded: loaded (/etc/systemd/system/abc.service; disabled; vendor preset: enabled)<br>
   Active: failed (Result: start-limit-hit) since Wed 2019-10-09 00:59:36 UTC; 4s ago<br>
  Process: 2895 ExecStart=/usr/bin/python -m abc.abc (code=exited, status=1/FAILURE)<br>
 Main PID: 2895 (code=exited, status=1/FAILURE)<br>
<br>
Oct 09 00:59:36 ip-172-26-4-222 systemd[1]: abc.service: Main process exited, code=exited, <br>status=1/FAILURE<br>
Oct 09 00:59:36 ip-172-26-4-222 systemd[1]: abc.service: Unit entered failed state.<br>
Oct 09 00:59:36 ip-172-26-4-222 systemd[1]: abc.service: Failed with result 'exit-code'.<br>
Oct 09 00:59:36 ip-172-26-4-222 systemd[1]: abc.service: Service hold-off time over, scheduling restart.<br>
Oct 09 00:59:36 ip-172-26-4-222 systemd[1]: Stopped abc Push Notification.<br>
Oct 09 00:59:36 ip-172-26-4-222 systemd[1]: abc.service: Start request repeated too quickly.<br>
Oct 09 00:59:36 ip-172-26-4-222 systemd[1]: Failed to start abc Push Notification.<br>
Oct 09 00:59:36 ip-172-26-4-222 systemd[1]: abc.service: Unit entered failed state.<br>
Oct 09 00:59:36 ip-172-26-4-222 systemd[1]: abc.service: Failed with result 'start-limit-hit'.<br>

我还尝试将ExecStart更改为

ExecStart=/bin/sh -c 'cd /home/bitnami/abc/ | python -m abc.abc',<br>


它也失败了。
谁能给我一个主意?
谢谢

0 个答案:

没有答案
相关问题