1
我使用http-server
來服務一個簡單的Angular應用程序。當我從bash運行它時,應用程序運行正常。但是當我嘗試從systemd單元文件運行時,它會失敗。http-server無法在systemd中啓動
這是我用來運行它的systemd單元文件。
[Unit]
Description=web_app
Requires=network.target
After=multi-user.target
[Service]
ExecStart=/usr/bin/http-server -p 80
Type=forking
WorkingDirectory=/home/ubuntu/jenkins/workspace/deepcareweb_dev
Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=web_app
User=root
#Group=<alternate group>
#Environment=NODE_ENV=production PORT=1337
[Install]
WantedBy=multi-user.target
我應該怎麼做,從systemd單元文件運行http-server
?
編輯1:systemctl status
$ sudo systemctl status web_app
● web_app.service - web_app
Loaded: loaded (/etc/systemd/system/web_app.service; enabled; vendor preset: enabled)
Active: inactive (dead) (Result: exit-code) since Sun 2017-03-05 06:17:14 UTC; 10s ago
Process: 1879 ExecStart=/usr/bin/http-server -p 80 (code=exited, status=200/CHDIR)
Main PID: 1354 (code=exited, status=200/CHDIR)
Mar 05 06:17:14 ip-172-31-22-251 systemd[1]: web_app.service: Control process exited, code=exited status=200
Mar 05 06:17:14 ip-172-31-22-251 systemd[1]: Failed to start web_app.
Mar 05 06:17:14 ip-172-31-22-251 systemd[1]: web_app.service: Unit entered failed state.
Mar 05 06:17:14 ip-172-31-22-251 systemd[1]: web_app.service: Failed with result 'exit-code'.
Mar 05 06:17:14 ip-172-31-22-251 systemd[1]: web_app.service: Service hold-off time over, scheduling restart.
Mar 05 06:17:14 ip-172-31-22-251 systemd[1]: Stopped web_app.
Mar 05 06:17:14 ip-172-31-22-251 systemd[1]: web_app.service: Start request repeated too quickly.
Mar 05 06:17:14 ip-172-31-22-251 systemd[1]: Failed to start web_app.
你如何運行它,你得到什麼錯誤? –
@BurhanKhalid當我運行'sudo systemctl start web_app'時,它表示'Job for web_app.service失敗,因爲控制進程退出並顯示錯誤代碼。有關詳細信息,請參閱「systemctl status web_app.service」和「journalctl -xe」。# –
...以及日誌說的是什麼? 'systemctl status web_app'? –