
TypeScriptファイルを実行するサービスを作成しようとしています。
これはこれまで私のサービスファイルの内容です。
[Unit]
Description=Service that runs the Parenti Bot
After=network.target
[Service]
Type=simple
User=abias
ExecStart=/home/abias/.local/share/pnpm/ts-node /home/abias/projects/lemmygrad-parenti-bot/bot.ts
Restart=on-failure
[Install]
WantedBy=multi-user.target
#!/usr/bin/env ts-node
ファイルの上部にshebangを追加しましたbot.ts
。私も走ることに決めたsudo chmod +x bot.ts
。これをすべて行ったにもかかわらず、sudo systemctl status
サービスで実行すると、次の結果が表示されます。
× parentibot.service - Service that runs the Parenti Bot
Loaded: loaded (/usr/lib/systemd/system/parentibot.service; disabled; preset: disabled)
Active: failed (Result: exit-code) since Thu 2022-12-08 17:50:32 EST; 11s ago
Duration: 6ms
Process: 283671 ExecStart=/home/abias/.local/share/pnpm/ts-node /home/abias/projects/lemmygrad-parenti-bot/bot.ts (code=e>
Main PID: 283671 (code=exited, status=203/EXEC)
CPU: 3ms
Dec 08 17:50:32 fedora systemd[1]: parentibot.service: Scheduled restart job, restart counter is at 5.
Dec 08 17:50:32 fedora systemd[1]: Stopped parentibot.service - Service that runs the Parenti Bot.
Dec 08 17:50:32 fedora systemd[1]: parentibot.service: Start request repeated too quickly.
Dec 08 17:50:32 fedora systemd[1]: parentibot.service: Failed with result 'exit-code'.
Dec 08 17:50:32 fedora systemd[1]: Failed to start parentibot.service - Service that runs the Parenti Bot.
私は何を間違えることができましたか?
編集する:実行出力sudo journalctl -xeu yourService.service
Dec 08 17:50:32 fedora systemd[1]: Stopped parentibot.service - Service that runs the Parenti Bot.
░░ Subject: A stop job for unit parentibot.service has finished
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ A stop job for unit parentibot.service has finished.
░░
░░ The job identifier is 22216 and the job result is done.
Dec 08 17:50:32 fedora systemd[1]: parentibot.service: Start request repeated too quickly.
Dec 08 17:50:32 fedora systemd[1]: parentibot.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ The unit parentibot.service has entered the 'failed' state with result 'exit-code'.
Dec 08 17:50:32 fedora systemd[1]: Failed to start parentibot.service - Service that runs the Parenti Bot.
░░ Subject: A start job for unit parentibot.service has failed
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ A start job for unit parentibot.service has finished with a failure.
░░
░░ The job identifier is 22216 and the job result is failed.
編集2:内容bot.ts
:見ることができますここ。
編集3:先ほど実行したところ、journalctl
次のエラーが表示されましたparentibot.service: Failed to locate executable /home/abias/.local/share/pnpm/ts-node
。これが問題のように見えますが、次の質問が提起されます。実行可能ファイルが見つからないのはなぜですか(実行可能ファイルがあるかどうかを確認しました)。
答え1
問題が何であるかを理解します。知っていると、それは私のユーザー/home/abias/.local/share/pnpm/ts-node
の場所でした。ts-node
使用するts-nodeの正しい位置はです/usr/bin/local/ts-node
。