태그 보관물: systemd

systemd

부팅시 활성화 된 시스템 서비스가 시작되지 않는 이유는 무엇입니까? kill-emacs-hook nil) (kill-emacs))” Restart=always Environment=DISPLAY=:%i TimeoutStartSec=0 [Install] WantedBy=default.target 부팅 할 때이

다음과 같은 시스템 단위 파일이 있습니다 /etc/systemd/system/emacs.service.

[Unit]
Description=Emacs: the extensible, self-documenting text editor
Documentatin=man:emacs(1) info:Emacs


[Service]
Type=forking
ExecStart=/usr/bin/emacs --daemon
ExecStop=/usr/bin/emacsclient --eval "(progn (setq kill-emacs-hook nil) (kill-emacs))"
Restart=always
Environment=DISPLAY=:%i
TimeoutStartSec=0

[Install]
WantedBy=default.target

부팅 할 때이 작업을 시작하고 싶습니다. systemctl enable emacs

그러나 서비스가 재부팅 될 때마다 systemctl status emacs다음이 표시됩니다.

● emacs.service - Emacs: the extensible, self-documenting text editor
   Loaded: loaded (/etc/systemd/system/emacs.service; disabled; vendor preset: enabled)
   Active: inactive (dead)

그러나 systemctl start emacs상태 를 입력 하고 확인하면 다음이 반환됩니다.

● emacs.service - Emacs: the extensible, self-documenting text editor
   Loaded: loaded (/etc/systemd/system/emacs.service; disabled; vendor preset: enabled)
   Active: active (running) since Fri 2016-11-11 23:03:59 UTC; 4s ago
  Process: 3151 ExecStart=/usr/bin/emacs --daemon (code=exited, status=0/SUCCESS)
 Main PID: 3154 (emacs)
    Tasks: 2
   Memory: 7.6M
      CPU: 53ms
   CGroup: /system.slice/emacs.service
           └─3154 /usr/bin/emacs --daemon

부팅시이 프로세스를 시작하려면 어떻게해야합니까?



답변

나는 왜 이것이 효과가 있는지 모르겠다.

삭제 Environment=DISPLAY=:%i

User=변수를 추가

올바른 파일이 있는지 확인하십시오 /etc/systemd/system/emacs.service(이전의 파일은 하드 링크 였습니다 )

재실행 systemctl enable emacs

이것은 작동하게 만들었습니다.

편집
여기에서 실제 문제는 3 줄에 오타가 있다는 것입니다.
Documentatin

확인하여 이것을 찾았습니다 journalctl. 시스템 스크립트에 문제가있는 사람은 stderr에 오류가 전송되지 않은 것과 동일한 작업을 수행하는 것이 좋습니다.


답변

이거 흥미 롭습니다.

임의의 서비스 단위를 선택하고 쳐다 보는 대신에 특정 대상에 의존합니다 default.target. 후자는 상징적입니다 … 특정 대상에 대한 구성된 링크, 의미 상 의미가 없습니다. (참조 systemctl set-default)

서비스 disabled를 활성화 한 후 서비스가 표시되는 이유를 설명 할 수 있습니다. 예를 들어 default.target서비스 파일 에서을 바꾸 십시오 multi-user.target.

(활성화하지 못할 때 오류를보고하지 않으면 systemd의 결함처럼 보입니다. 디렉토리가 있는지 거의 궁금합니다 /etc/systemd/system/default.target.wants).


답변

DISPLAY 환경 변수가 있습니다. 즉, X11을 시작하려고합니다. 따라서 그때까지 서비스를 차단할 수있는 방법이 필요합니다.

이것은 옵션을 사용 하여After=... 수행됩니다 .

나는 그것을 스스로하지 않았으므로 그것이 효과가 있다고 말할 수는 없지만 아마도 관련이있을 것입니다 graphical.target.

[Unit]
After=graphical.target

X 서버가 즉시 시작되지 않는 경우 (즉, lightdm 등으로 로그인 화면이있는 경우) WantedBy=...대신 다음 을 사용해야 할 수도 있습니다 .

[Unit]
WantedBy=graphical.target

systemd로 작업하는 데 지치면 X-Windows 관리자가 일반적인 방식으로 조사해 볼 수 있습니다.

~/.xprofile같은 작품 파일, ~/.bashrc파일.

~/.config/autostart/*.desktop파일 도 있습니다. 거기에 정의 된 응용 프로그램이 자동으로 시작됩니다.

이 솔루션은 시스템 전체에 적용되지는 않지만 여러 사용자가있는 경우 각 사용자마다 고유 한 항목이 있어야합니다. 또한 응용 프로그램을 루트로 시작하지 않고 대신 사용자로 시작합니다.


참고로 “loaded + inactive (dead)”메시지는 systemd가 프로세스를 시작하는 데 어려움을 겪고 결과적으로 프로세스를 포기 하기로 결정했음을 의미 합니다. name.service다음을 사용하여 재부팅 한 후 작동하는지 수동으로 테스트 할 수 있습니다 .

systemctl stop <service-name>
systemctl start <service-name>

정보가 정확하다고 가정하면 상태 가 새로 고쳐 지고 서비스가 올바르게 시작됩니다. 그런 다음 상태를 다시 확인하여 추가 세부 사항을 볼 수 있습니다.

 systemctl status <service-name>

답변

데비안의 여러 서비스 파일에있는 버그입니다.

# systemctl enable watchdog
Synchronizing state of watchdog.service with SysV init with /lib/systemd/systemd-sysv-install...
Executing /lib/systemd/systemd-sysv-install enable watchdog
# find /etc/systemd/ | grep watch
# tail -n2 /lib/systemd/system/watchdog.service

[Install]

https://www.raspberrypi.org/forums/viewtopic.php?f=82&t=218609&p=1406567#p1406567
https://forum.armbian.com/topic/9115-still-dont-know-where-to-report -bugs-watchdogservice-refuses-to-start-due-to-broken-service-file /

배포 수준 수정은

echo "WantedBy=default.target" >> /lib/systemd/system/watchdog.service
systemctl daemon-reexec
systemctl enable watchdog
systemctl stop watchdog.service
systemctl start watchdog.service

이에 대한 많은 수동 대안이 있습니다.


답변