Chromium을 서비스로 실행할 수 없습니다.

Chromium을 서비스로 실행할 수 없습니다.

펄스 오디오를 실행해야 하기 때문에 크롬을 서비스로 실행하려고 합니다.

서비스 파일은 다음과 같습니다.

[Unit]
Description = Kiosk launcher as service
After = pulseaudio.service
Wants =
Requires =

[Service]
Type = simple
PIDFile = /var/run/kiosk.pid
ExecStart = /usr/bin/chromium --no-sandbox /var/www/Kiosk/trunk/indexLocker.php
Restart = on-abort
StartLimitInterval = 60
StartLimitBurst = 10

[Install]
WantedBy =

달려가 systemctl start kiosk는데 아무 일도 일어나지 않습니다.
상태 옵션의 출력은 다음과 같습니다.

● kiosk.service - Kiosk launcher as service
Loaded: loaded (/etc/systemd/system/kiosk.service; static; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2022-07-21 17:38:37 CEST; 8s ago
Process: 9283 ExecStart=/usr/bin/chromium --no-sandbox /var/www/Kiosk/trunk/indexLocker.php (code=exited, sta    
Main PID: 9283 (code=exited, status=1/FAILURE)

Jul 21 17:38:37 tinkerboard systemd[1]: kiosk.service: Failed with result 'exit-code'.

나는 출력을 더 잘 보여주기 위해 여기에 이것을 쓰고 있습니다.

linaro@tinkerboard:~/.config/systemd/user$ ls -la
total 12
drwxr-xr-x 2 linaro linaro 4096 Jul 22 09:22 .
drwxr-xr-x 3 linaro linaro 4096 Jul 21 17:11 ..
-rw-r--r-- 1 linaro linaro  327 Jul 22 09:22 kiosk.service
linaro@tinkerboard:~/.config/systemd/user$ 
linaro@tinkerboard:~/.config/systemd/user$ systemctl --user start kiosk
Failed to start kiosk.service: Unit kiosk.service not found.
linaro@tinkerboard:~/.config/systemd/user$ 
linaro@tinkerboard:~/.config/systemd/user$ echo $HOME
/home/linaro
linaro@tinkerboard:~/.config/systemd/user$ whoami
linaro
linaro@tinkerboard:~/.config/systemd/user$ 

죄송합니다. 문제가 보이지 않습니다..

- - 추가- -

linaro@tinkerboard:~/.config/systemd/user$ strace -e trace=file systemctl --user start kiosk > output
execve("/bin/systemctl", ["systemctl", "--user", "start", "kiosk"], [/* 39 vars */]) = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/lib/systemd/tls/v7l/neon/vfp/libsystemd-shared-232.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/systemd/tls/v7l/neon/vfp", 0xbed08cc0) = -1 ENOENT (No such file or directory)
open("/lib/systemd/tls/v7l/neon/libsystemd-shared-232.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/systemd/tls/v7l/neon", 0xbed08cc0) = -1 ENOENT (No such file or directory)
open("/lib/systemd/tls/v7l/vfp/libsystemd-shared-232.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/systemd/tls/v7l/vfp", 0xbed08cc0) = -1 ENOENT (No such file or directory)
open("/lib/systemd/tls/v7l/libsystemd-shared-232.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/systemd/tls/v7l", 0xbed08cc0) = -1 ENOENT (No such file or directory)
open("/lib/systemd/tls/neon/vfp/libsystemd-shared-232.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/systemd/tls/neon/vfp", 0xbed08cc0) = -1 ENOENT (No such file or directory)
open("/lib/systemd/tls/neon/libsystemd-shared-232.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/systemd/tls/neon", 0xbed08cc0) = -1 ENOENT (No such file or directory)
open("/lib/systemd/tls/vfp/libsystemd-shared-232.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/systemd/tls/vfp", 0xbed08cc0) = -1 ENOENT (No such file or directory)
open("/lib/systemd/tls/libsystemd-shared-232.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/systemd/tls", 0xbed08cc0)  = -1 ENOENT (No such file or directory)
open("/lib/systemd/v7l/neon/vfp/libsystemd-shared-232.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/systemd/v7l/neon/vfp", 0xbed08cc0) = -1 ENOENT (No such file or directory)
open("/lib/systemd/v7l/neon/libsystemd-shared-232.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/systemd/v7l/neon", 0xbed08cc0) = -1 ENOENT (No such file or directory)
open("/lib/systemd/v7l/vfp/libsystemd-shared-232.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/systemd/v7l/vfp", 0xbed08cc0) = -1 ENOENT (No such file or directory)
open("/lib/systemd/v7l/libsystemd-shared-232.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/systemd/v7l", 0xbed08cc0)  = -1 ENOENT (No such file or directory)
open("/lib/systemd/neon/vfp/libsystemd-shared-232.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/systemd/neon/vfp", 0xbed08cc0) = -1 ENOENT (No such file or directory)
open("/lib/systemd/neon/libsystemd-shared-232.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/systemd/neon", 0xbed08cc0) = -1 ENOENT (No such file or directory)
open("/lib/systemd/vfp/libsystemd-shared-232.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/systemd/vfp", 0xbed08cc0)  = -1 ENOENT (No such file or directory)
open("/lib/systemd/libsystemd-shared-232.so", O_RDONLY|O_CLOEXEC) = 3
open("/lib/systemd/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = 3
open("/lib/systemd/libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
open("/lib/systemd/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/libselinux.so.1", O_RDONLY|O_CLOEXEC) = 3
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/libcap.so.2", O_RDONLY|O_CLOEXEC) = 3
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/librt.so.1", O_RDONLY|O_CLOEXEC) = 3
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/liblzma.so.5", O_RDONLY|O_CLOEXEC) = 3
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/usr/lib/arm-linux-gnueabihf/liblz4.so.1", O_RDONLY|O_CLOEXEC) = 3
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/libgcrypt.so.20", O_RDONLY|O_CLOEXEC) = 3
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/libacl.so.1", O_RDONLY|O_CLOEXEC) = 3
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/libidn.so.11", O_RDONLY|O_CLOEXEC) = 3
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/libseccomp.so.2", O_RDONLY|O_CLOEXEC) = 3
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/libpcre.so.3", O_RDONLY|O_CLOEXEC) = 3
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/libgpg-error.so.0", O_RDONLY|O_CLOEXEC) = 3
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/libattr.so.1", O_RDONLY|O_CLOEXEC) = 3
statfs("/sys/fs/selinux", 0xbed0a2a4)   = -1 ENOENT (No such file or directory)
statfs("/selinux", 0xbed0a2a4)          = -1 ENOENT (No such file or directory)
open("/proc/filesystems", O_RDONLY)     = 3
access("/etc/selinux/config", F_OK)     = -1 ENOENT (No such file or directory)
open("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/locale/C.UTF-8/LC_IDENTIFICATION", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/arm-linux-gnueabihf/gconv/gconv-modules.cache", O_RDONLY) = 3
open("/usr/lib/locale/C.UTF-8/LC_MEASUREMENT", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/locale/C.UTF-8/LC_TELEPHONE", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/locale/C.UTF-8/LC_ADDRESS", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/locale/C.UTF-8/LC_NAME", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/locale/C.UTF-8/LC_PAPER", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/locale/C.UTF-8/LC_MESSAGES", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/locale/C.UTF-8/LC_MESSAGES/SYS_LC_MESSAGES", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/locale/C.UTF-8/LC_MONETARY", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/locale/C.UTF-8/LC_COLLATE", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/locale/C.UTF-8/LC_TIME", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/locale/C.UTF-8/LC_NUMERIC", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/locale/C.UTF-8/LC_CTYPE", O_RDONLY|O_CLOEXEC) = 3
open("/proc/self/stat", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
stat64("/proc/1/root", 0xbed0a108)      = -1 EACCES (Permission denied)
open("/sys/fs/kdbus/1000-user/bus", O_RDWR|O_NOCTTY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
Failed to start kiosk.service: Unit kiosk.service not found.
+++ exited with 5 +++

파일에 액세스하려는 시도가 발견되지 않았습니다.

-- 2씩 증가 --

나는 타이핑을 놓쳤다 systemctl --user daemon-reload.
이제 서비스를 찾았지만 아무 일도 일어나지 않습니다.

linaro@tinkerboard:~/.config/systemd/user$ systemctl --user status kiosk
● kiosk.service - Kiosk launcher as service
   Loaded: loaded (/home/linaro/.config/systemd/user/kiosk.service; static; vendor preset: enabled)
   Active: failed (Result: exit-code) since Fri 2022-07-22 15:01:55 CEST; 2min 28s ago
  Process: 3489 ExecStart=/usr/bin/chromium (code=exited, status=1/FAILURE)
 Main PID: 3489 (code=exited, status=1/FAILURE)

Jul 22 15:01:54 tinkerboard systemd[1184]: Started Kiosk launcher as service.
Jul 22 15:01:55 tinkerboard systemd[1184]: kiosk.service: Main process exited, code=exited, status=1/FAILURE
Jul 22 15:01:55 tinkerboard systemd[1184]: kiosk.service: Unit entered failed state.
Jul 22 15:01:55 tinkerboard systemd[1184]: kiosk.service: Failed with result 'exit-code'.

-- 3씩 증가 --

명령줄에 --enable-logging을 추가했더니 로그 디버그가 생성되었습니다.

[4837:4837:0722/155433.606728:WARNING:browser_main_loop.cc(297)] Gtk: cannot open display: 

표시 변수가 누락되었습니까? 왜?

- 갱신 -

스크립트를 실행하기 위해 ExecStart를 수정했습니다. 스크립트 명령줄에 DISPLAY 변수가 추가되었습니다.

[Unit]
Description = Kiosk launcher as service
After = pulseaudio.service
Wants = 
Requires = 

[Service]
Type = simple
ExecStart = /home/amtek/launchService.sh
Restart = always

[Install]
WantedBy = graphical-session.target

서비스를 수동으로 실행하면 systemctl --user start kiosk브라우저에서 서비스가 시작됩니다. 브라우저를 닫으면 브라우저가 다시 시작됩니다.

하지만 컴퓨터를 다시 시작하면 브라우저가 자동으로 시작되지 않고 dmesg 또는 syslog에서 오류 메시지를 찾을 수 없습니다.

유일한 단서는 다음과 같습니다.

linaro@tinkerboard:~$ systemctl --user status kiosk
● kiosk.service - Kiosk launcher as service
   Loaded: loaded (/home/linaro/.config/systemd/user/kiosk.service; enabled; vendor preset: enabled)
   Active: inactive (dead)

답변1

이것은 systemd 버스에서 실행됩니다 --system. 귀하의 서비스 파일이 에 있기 때문에 우리는 이것을 알고 있습니다 /etc/systemd/system. 문제는 root일반적으로 데스크톱 세션이 없다는 것입니다. 루트에 하나 이상의 데스크톱 세션이 있더라도 이 창이 표시되는 세션을 정의해야 합니다.

systemd의 버스 --user에서 실행하십시오 . 이렇게 하면 크롬이 루트로 실행되지 않고 로그인한 사용자로 실행됩니다. 더 중요한 것은 서비스 환경이 로그인한 사용자의 DISPLAY환경 XAUTHORITY변수를 상속하게 된다는 것입니다.

버스에서 달리기 --user:

  1. kiosk.service파일을 로 이동합니다 ~/.config/systemd/user/. 디렉터리가 없으면 만듭니다.
  2. WantedBy=사용자 버스에 존재하는 것으로 설정합니다 . 가장 좋은 방법은 를 사용하는 것입니다 graphical-session.target. 이렇게 하면 데스크톱이 준비될 때만 크롬이 시작됩니다. 이는 대부분의(전부는 아님) 데스크탑 환경에서 작동합니다. 아직 graphic-session.target을 구현하지 않은 것을 사용하는 경우(또는 xinit직접 호출하는 경우) WantedBy=default.target.
  3. systemctl --user start kiosk.service(사용하지 않음)을 사용하여 sudo서비스를 테스트하세요 .

또는 버스에서 계속 실행할 수 있지만 --system다음을 설정해야 합니다.

  1. Environment=DISPLAY=:0 XAUTHORITY=/run/user/1000/gdm/Xauthority(이 값을 디스플레이와 관련된 값으로 바꾸십시오).
  2. WantedBy=graphical.target모니터가 실행된 후에만 시작하십시오.
  3. User=kioskuser사용자에게 루트 권한을 부여하지 않으려면

관련 정보