0
私はsystemd
サービススクリプトを書くのが初めてです。私はこのuseful pageをフォローしていました。以下のように失敗しています。 Centos 7
マシンで/etc/systemd/system/
でsystemd経由でPythonスクリプトを実行する
prodKPI.service
内容は、私は、ファイルを作成した後に続い
[Unit]
Description=prodKPI: Aggregation logic to compute device availability
[Service]
Type=simple
PermissionsStartOnly=true
User=deployuser
ExecStart = /usr/bin/python /tmp/app1/folder1/file1.py; /usr/bin/python /tmp/folder2/file2.py
Restart=always
[Install]
WantedBy=default.target
ステップとしてある
systemctl daemon-reload
systemctl enable prodKPI.service
はreboot
と
# systemctl status prodKPI.service
● prodKPI.service - prodKPI: Aggregation logic to compute device availability
Loaded: loaded (/etc/systemd/system/prodKPI.service; enabled; vendor preset: disabled)
Active: failed (Result: start-limit) since Fri 2017-07-21 19:20:41 UTC; 15min ago
Process: 1190 ExecStart=/usr/bin/python /tmp/app1/folder1/file1.py; /usr/bin/python /tmp/folder2/file2.py (code=exited, status=2)
Main PID: 1190 (code=exited, status=2)
Jul 21 19:20:41 device-1 systemd[1]: prodKPI.service: main process exited, code=exited, status=2/INVALIDARGUMENT
Jul 21 19:20:41 device-1 systemd[1]: Unit prodKPI.service entered failed state.
Jul 21 19:20:41 device-1 systemd[1]: prodKPI.service failed.
Jul 21 19:20:41 device-1 systemd[1]: prodKPI.service holdoff time over, scheduling restart.
Jul 21 19:20:41 device-1 systemd[1]: start request repeated too quickly for prodKPI.service
Jul 21 19:20:41 device-1 systemd[1]: Failed to start prodKPI.service: Aggregation logic to compute device availability.
Jul 21 19:20:41 device-1 systemd[1]: Unit prodKPI.service entered failed state.
Jul 21 19:20:41 device-1 systemd[1]: prodKPI.service failed.
これをやっています助けにはならなかった
journalctl -xe
-- Unit prodKPI.service has finished starting up.
--
-- The start-up result is done.
Jul 21 19:20:41 device-1 systemd[1]: Starting prodKPI.service: Aggregation logic to compute device availability...
-- Subject: Unit prodKPI.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit prodKPI.service has begun starting up.
Jul 21 19:20:41 device-1 python[1190]: /usr/bin/python: can't open file '/tmp/app1/folder1/file1.py;': [Errno 2] No such file or directory
Jul 21 19:20:41 device-1 systemd[1]: prodKPI.service: main process exited, code=exited, status=2/INVALIDARGUMENT
Jul 21 19:20:41 device-1 systemd[1]: Unit prodKPI.service entered failed state.
Jul 21 19:20:41 device-1 systemd[1]: prodKPI.service failed.
Jul 21 19:20:41 device-1 systemd[1]: prodKPI.service holdoff time over, scheduling restart.
Jul 21 19:20:41 device-1: start request repeated too quickly for prodKPI.service
Jul 21 19:20:41 device-1: Failed to start prodKPI.service: Aggregation logic to compute device availability.
以下のエラーラインは、何らかの許可の問題を示していますか?サービスユニットを別のユーザー(または)のアクセスレベルで実行する必要がありますか?私はタイプはないワンショットのときも
Jul 21 19:20:41 device-1 python[1190]: /usr/bin/python: can't open file '/tmp/app1/folder1/file1.py;': [Errno 2] No such file or directory
答えをありがとう。私は今サービスを稼働させることができます。私にはいくつかの説明があります。 1)最初のpythonスクリプトの '/ usr/bin/python'を意味しましたか? 2)この 'bash -c'オプションを使うと、バックグラウンドで実行されている最初のスクリプトだけが' ps -ef | grep [p] ython'と2番目のスクリプトが実行されているのを見ることができませんか?どのようにそれを実行するようにどのようなアイデア?喜んで答えを受け入れるでしょう – Inian
最終的に問題の修正を見つけました! – Inian