2

I'm trying to run a chromium as a service cause I need the pulseaudio is running.

The service file is:

[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 =

I run the systemctl start kiosk but nothing happen.
The output of the status option is:

● 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'.

I write here just to display better the outputs:

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$ 

I'm sorry but I'm not able to see the problem ..

--- ADDED ---

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 +++

I do not find the attempt to access the file ...

-- ADDED 2 --

I missed to type systemctl --user daemon-reload.
Now the service is found but nothing happens.

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'.

-- ADDED 3 --

I added the --enable-logging on the command line and a log debug is generated.

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

Is the display variable missed? Why?

-- UPDATE --

I modified the ExecStart to run a script. added the DISPLAY variable on the command line in the script.

[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

If I manually run the service by systemctl --user start kiosk the browser starts. If I close the browser, the browser restarts.

But If I reboot the machine, the browser is not automatically started and I'm not able to find any error message in dmesg or syslog.

The only clue is:

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
  • Cannot open display leads me to think you didn't specify the DISPLAY variable. Commented Jul 31, 2022 at 7:55

1 Answer 1

3

This is running on systemd's --system bus. We know that because your service file is in /etc/systemd/system. The problem is that root usually doesn't have a desktop session. Even if root had one (or more) desktop sessions, you would need to define which session to display this window on.

Run this on systemd's --user bus instead. That will cause chromium to run as your logged-in user (instead of running as root). More importantly, it will cause the service's environment to inherit the logged-in user's DISPLAY and XAUTHORITY environment variables.

To run on the --user bus:

  1. Move kiosk.service file to ~/.config/systemd/user/. If that directory doesn't exist, create it.
  2. Set your WantedBy= to something that exists on the user-bus. The best case is to use graphical-session.target. This will cause chromium to launch only after your desktop is ready. This works for most (but not all) desktop environments. If you are using something that hasn't implemented graphical-session.target (or perhaps you are calling xinit yourself), then use WantedBy=default.target.
  3. Test your service with systemctl --user start kiosk.service (don't use sudo)

Alternatively, you could continue to run this on the --system bus, but you would need to set:

  1. Environment=DISPLAY=:0 XAUTHORITY=/run/user/1000/gdm/Xauthority (replacing the values with what is relevant to your display).
  2. WantedBy=graphical.target to ensure this only starts after you have a display running
  3. User=kioskuser to avoid giving your users root permissions.
6
  • Thanks a lot. I was also trying the --user way but I always receive Failed to start kiosk.service: Unit kiosk.service not found but the file is there, under the ~/.config/systemd/user folder.
    – SteMMo
    Commented Jul 22, 2022 at 7:32
  • People often get that error if they run sudo systemctl --user .... That's because sudo will look in /root/.config.... Avoid using sudo when working with the user-bus.
    – Stewart
    Commented Jul 22, 2022 at 7:34
  • I'm not using sudo ..
    – SteMMo
    Commented Jul 22, 2022 at 7:41
  • Does the service file have particular rights?
    – SteMMo
    Commented Jul 22, 2022 at 7:45
  • Does the location of ~ match the location of $HOME? Do you have kiosk.service in a sub-directory (don't do that)? Does kiosk.service have the .service extension? If you aren't using sudo, check the spelling of your paths. ~/.config/systemd/user/* is hard-coded into systemd, so being unable to find that file isn't a systemd problem. See systemd.unit(5) for a list of places systemd looks to find the file.
    – Stewart
    Commented Jul 22, 2022 at 7:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .