systemd 서비스에서 ts-node 실행

systemd 서비스에서 ts-node 실행

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.

관련 정보