5

I'm running raspbian on pi. I've created a systemd script which runs a node.js app on startup.

Script:

#!/usr/bin/env bash
cd /home/pi/pop_machine && /usr/bin/npm start

Systemd Service:

[Service]
ExecStart=/home/pi/pop_machine/start_pop.sh

[Install]
WantedBy=default.target

The script works if I run it manually but not on startup. I'm wondering if it's because it tries to run before its dependencies.

I've seen people require networking before running by adding a line to [install] is there something similar where I can wait until everything to run a GUI application is ready?

I assume I just need x-window?

8

Solved by adding these to service:

[Service]
Environment="DISPLAY=:0"
Environment="XAUTHORITY=/home/pi/.Xauthority"

[Install]
WantedBy=graphical.target
4
  • Probably you also enable and start it. You didn't use .timer?
    – Pablo A
    Dec 21 '18 at 23:00
  • I'm on Ubuntu and that graphical.target works great. I also have the Environment="DISPLAY=:0". However, the .Xauthority, I did not try with that one. I don't think it's saved at that location anymore anyway. Jul 2 at 16:49
  • @PabloA Why would you start a GUI app. on a timer?! Jul 2 at 16:51
  • This was long time ago, I'm not sure what I meant with the timer. BTW, could be useful on some cases. Also, you probably enabled the service also, you could mention that (obvious, though). Did you mean you didn't try without .Xauthority? If it's necessary, could be useful its content.
    – Pablo A
    Jul 2 at 21:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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