Initialize and monitor electron app via `systemd` at system startup


#1

We have some kiosks (unmanned) and we’re using electron as the front end of them (Running on Ubuntu 16.04).

My question is on how to handle automatic launching of electron at startup via systemd (or similar init system).

Right now, my ux.service file looks like this:


[Unit]
Description=Kiosk UX service
Requires=graphical.target
After=graphical.target

[Service]
User=myuser
StartLimitInterval=5
StartLimitBurst=10
Environment=DISPLAY=:0.0
ExecStart=/usr/local/lib/npm/bin/electron /home/myuser/dev/kiosk-ux

Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target

But not starting it at boot time. Any idea of what am I missing?

Thanks,

p.s. Once started (manually through sudo systemctl start ux.service, it does run it and monitors its running state (restarts if I kill the elctron process), but it doesn’t start it at boot time.


#2

This sounds like a systemd question, not an Electron question. Are you able to start other applications through that method?


#3

Me too,

My electron app just won’t start!

But I have found that, the similar VNC server service script will. I just don’t know why?

/usr/lib/systemd/system/vncserver-x11-serviced.service

[Unit]
Description=VNC Server in Service Mode daemon
After=network.target

[Service]
ExecStart=/usr/bin/vncserver-x11-serviced -fg
ExecReload=/bin/kill -HUP
Restart=on-failure
KillMode=process

[Install]
WantedBy=multi-user.target

#4

Can anyone succeed in getting electron app work with systemd? I am struggling with same issue now. :frowning: Any help would be greatly appreciated.