0

The Want: opening a program at boot in a Weston compositor

What I've tried: creating a SysV init script with a low priority

What Works: Weston launches, but my program does not

Hello, I'm working on a program in an embedded environment. The program is Qt based, and I'd like it to run when the device boots up. This device uses a Debian-like distro, with the exception that when it boots, it boots straight to a Weston compositor, rather than a login/desktop.

What I've done so far is created a standard /etc/init.d script (shown below) that launches my program using start-stop-daemon and has a simple start-stop toggle. This works if called manually, however, using update-rc.d appService defaults results in the program not starting at boot.

If I try manually launching the service automatically generates (systemctl start appService), I receive an XDG_RUNTIME_DIR error. What??? Why is X getting in my way?

Investigating the .service file that systemd autogenerates (also shown below) the program wants to run before the multi-user.target runlevel has been reached.

The script

#!/bin/sh

DIR="/home/root"
DAEMON=$DIR/appname
DAEMON_OPTS=""
DAEMON_NAME="APP"
PIDFILE=/var/run/$DAEMON_NAME.pid
DAEMON_USER="root"

case "$1" in
  start)
    echo "Starting $DAEMON_NAME"
    ifconfig eth1 192.168.1.233
    start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --user $DAEMON_USER --chuid $DAEMON_USER --exec $DAEMON -- $DAEMON_OPTS
    ;;
  stop)
    echo "Stopping $DAEMON_NAME"
    start-stop-daemon --stop --pidfile $PIDFILE --retry 10
    ;;
  *)
    echo "Usage: /etc/init.d/appService {start|stop}"
    exit 1
    ;;
esac

exit 0

The service file:

[Unit]
Documentation=man:systemd-sysv-generator(8)
SourcePath=/etc/init.d/appService
Before=multi-user.target
Before=multi-user.target
Before=multi-user.target
Before=graphical.target
Before=shutdown.target
Before=umountnfs.service
Before=rng-tools.service
Before=thermal-zone-init.service
Before=gdbserverproxy.service
After=dropbear.service
After=tiipclad-daemon.service
After=telnetd.service
After=rc.pvr.service
After=uim-sysfs.service
After=alignment.service
Conflicts=shutdown.target

[Service]
Type=forking
Restart=no
TimeoutSec=5min
IgnoreSIGPIPE=no
KillMode=process
GuessMainPID=no
RemainAfterExit=yes
ExecStart=/etc/init.d/appService start
ExecStop=/etc/init.d/appService stop

If I try manually launching the service(systemctl start appService), I receive an XDG_RUNTIME_DIR error. What??? Why is X getting in my way?

How can I fix this script? I want to have it launch after the Weston compositor launches

  • If you have a systemd .service, what is the point of /etc/init.d/appService? It just duplicates what systemd has already done. – grawity Mar 7 '18 at 18:17
1

X11 requires some environment variables to be set for apps to start properly under X11. Have you confirmed what environment variables need to be set to launch apps under Weston?

In my experience, a better choice for auto-starting graphical apps to use a desktop environments "start-up apps" feature than systemd. In that design, the proper environment variables will already be set for you.

  • As I mentioned, I don't have a desktop environment. Behind Weston is a simple fb0 framebuffer, with a weson instance running on top. I couldn't get an X session going if I tried. – T. Wallis Mar 7 '18 at 19:54
  • Have you confirmed what environment variables need to be set to launch apps under Weston? – Mark Stosberg Mar 7 '18 at 20:13
  • I found it, there was a wayland_env.sh file that I wasn't sourcing. It works now! – T. Wallis Mar 7 '18 at 21:53
  • If my answer was helpful, please consider upvoting and accepting it. – Mark Stosberg Mar 9 '18 at 18:22

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.