systemd는 서비스의 시작 순서를 제어합니다.

systemd는 서비스의 시작 순서를 제어합니다.

두 개의 시스템 서비스 파일이 있습니다. gw_web.service그 이후에 시작하고 싶어요 gw_log.service.

다음은 두 가지 서비스 파일입니다.

gw_log.service:

[Unit]
Description=myGarage Log Service
After=multi-user.target

[Service]
Type=idle
User=pi
Restart=always
RestartSec=1
ExecStartPre=-/usr/bin/rm /home/pi/myprojects/myGarage/gw_log.service.log
ExecStart=/usr/bin/python3 -u /home/pi/myprojects/myGarage/gw_log.py
StandardOutput=file:/home/pi/myprojects/myGarage/gw_log.service.log

[Install]
WantedBy=multi-user.target

gw_web.service:

[Unit]
Description=myGarage Web Service
Requires=gw_log.service
After=gw_log.service

[Service]
Type=idle
User=pi
Restart=always
RestartSec=1
ExecStartPre=-/usr/bin/rm /home/pi/myprojects/myGarage/gw_web.service.log
ExecStart=/usr/bin/python3 -u /home/pi/myprojects/myGarage/gw_web.py
StandardOutput=file:/home/pi/myprojects/myGarage/gw_web.service.log

[Install]
WantedBy=multi-user.target

서버를 다시 시작하면 서버 gw_log.service만 활성화됩니다. gw_web.service사망 한. 그렇다면 systemctl start gw_web모든 것이 잘 작동합니다. 하지만 시작시에는 작동하지 않습니다.

이 서비스를 비활성화했다가 다시 활성화했습니다. 재미가 없습니다. 내가 뭘 잘못했나요?

업데이트: gw_web.service/start 및 multi-user.target/start의 구독 주기로 인해 gw_web.service를 시작할 수 없습니다. Unit 섹션을 추가하여 DefaultDependencies=no이 문제를 해결했습니다.gw_web.service

관련 정보