0

I'm trying to set up Raspberry Pi with Raspbian to run a single program - PrintNode to manage printing. Program is placed in a file in desktop, and according to readme file, it is supposed to work by typing ./PrintNode inside the file - which works, when I do it.

I've found information, that the best way to handle autostart would be creating service through Unit file. So what I did was following:

Created new service file:

sudo nano /lib/systemd/system/PrintNode.service

content:

[Unit]
Description=PrintNode Service
After=multi-user.target
[Service]
Type=idle
User=pi
ExecStart=/home/pi/Desktop/PrintNode/PrintNode
Restart=always
RestartSec=0

[Install]
WantedBy=multi-user.target

Restarting

sudo systemctl daemon-reload
sudo systemctl enable Printnode.service

Now, after rebooting and trying

sudo systemctl status PrintNode.service

it is active (running) however PrintNode application has not been started.

I suppose I did not understand fully the idea of using systemd autostart or there is an error somewhere. I would really appreciate your help in understanding how it should work.

pi@print-server:~ $ cat /home/pi/Desktop/PrintNode
cat: /home/pi/Desktop/PrintNode: Is a directory

pi@print-server:~/Desktop/PrintNode $ ls
build.json      lib          readme.txt       sample_config.conf
CHANGE_LOG.txt  LICENSE.txt  readme.txt.save  udev-rule-generator
init.sh         PrintNode    resources        VERSION
pi@print-server:~/Desktop/PrintNode $ 

edit:

pi@print-server:~ $ systemctl status PrintNode.service
* PrintNode.service - PrintNode Service
   Loaded: loaded (/etc/systemd/system/PrintNode.service; enabled; vendor preset
   Active: active (running) since Sun 2020-11-01 12:51:05 CET; 177ms ago
 Main PID: 3780 (PrintNode)
    Tasks: 1 (limit: 4915)
   CGroup: /system.slice/PrintNode.service
           `-3780 /home/pi/Desktop/PrintNode/PrintNode

Nov 01 12:51:05 print-server systemd[1]: Started PrintNode Service.

journalctl -b -e gave following information, repeating on and on:

Nov 01 20:35:44 print-server systemd[1]: PrintNode.service: Main process exited, code=exited, status=1/FAILURE
Nov 01 20:35:44 print-server systemd[1]: PrintNode.service: Failed with result 'exit-code'.
Nov 01 20:35:44 print-server systemd[1]: PrintNode.service: Service has no hold-off time (RestartSec=0), scheduling restart.
Nov 01 20:35:44 print-server systemd[1]: PrintNode.service: Scheduled restart job, restart counter is at 10.
Nov 01 20:35:44 print-server systemd[1]: Stopped PrintNode Service.
Nov 01 20:35:44 print-server systemd[1]: Started PrintNode Service.

content of one of the log files inside /home/pi/.printnode/printnode/11/logs/ (they all seem to be the same):

2020-11-01 20:44:40,849  launch_linux.py       41     INFO        main                           BUILD CONFIGURATION version:4.24.1 edition:printnode develop:False info:[{"build_time":"2020-05-29T02:06:46","build_machine":{"system":"Linux","platform":"Linux-4.19.66-v7+-armv7l-with-debian-10.4","machine":"armv7l","architecture":"32bit","host":"amalthea-buster"},"client":{"commit":"094126d346c3c55c94bccfd71a3a83dcace3e2ed","datetime":"2020-05-28T22:44:33"},"clientbuildsystem":{"commit":"a64b63e29eca78ab7d08253de4524f7a17bdd8f3","datetime":"2020-02-06T20:55:50"},"clienteditions":{"commit":"5ebec172a981ca7b9cdfe0dd320a18d3196a3421","datetime":"2020-05-06T12:59:26"}},["094126d346c3c55c94bccfd71a3a83dcace3e2ed","a64b63e29eca78ab7d08253de4524f7a17bdd8f3","5ebec172a981ca7b9cdfe0dd320a18d3196a3421"]]
2020-11-01 20:44:40,854  launch_linux.py       41     INFO        main                           PYTHON  : 3.6.10+
2020-11-01 20:44:40,854  launch_linux.py       41     INFO        main                           SYSTEM  : Linux
2020-11-01 20:44:40,855  launch_linux.py       41     INFO        main                           MACHINE : armv7l
2020-11-01 20:44:40,855  launch_linux.py       41     INFO        main                           VERSION : ('debian', '10.6', '')
2020-11-01 20:44:40,857  launch_linux.py       41     INFO        main                           user, hostname, cwd : pi, print-server, /home/pi/Desktop/PrintNode
2020-11-01 20:44:40,857  launch_linux.py       41     DEBUG       main                           Error creating default file to /etc/PrintNode/config.conf; [Errno 2] No such file or directory: '/etc/PrintNode/config.conf'
2020-11-01 20:44:40,859  launch_linux.py       41     DEBUG       main                           Config app-default/remove_scales_support value False
2020-11-01 20:44:40,859  launch_linux.py       41     DEBUG       main                           Config app-default/startup_mutex value True
2020-11-01 20:44:40,860  launch_linux.py       41     DEBUG       main                           Config app-default/headless value False
2020-11-01 20:44:40,861  launch_linux.py       41     DEBUG       main                           Config app-default/disable_systray value False
2020-11-01 20:44:40,862  launch_linux.py       41     DEBUG       main                           Config app-default/shutdown_on_sigint value False
2020-11-01 20:44:40,863  launch_linux.py       41     DEBUG       main                           Config app-default/web_interface value False
2020-11-01 20:44:40,864  launch_linux.py       41     DEBUG       main                           Config app-default/web_interface_port value 8888
2020-11-01 20:44:40,865  launch_linux.py       41     DEBUG       main                           Config app-default/web_interface_shutdown value False
2020-11-01 20:44:40,866  launch_linux.py       41     DEBUG       main                           Config command-line/config_file value /etc/PrintNode/config.conf
2020-11-01 20:44:40,866  launch_linux.py       41     DEBUG       main                           Config command-line/config_file_using_default value True
2020-11-01 20:44:40,867  launch_linux.py       41     DEBUG       main                           Config command-line/disable_printer_removal value False
2020-11-01 20:44:40,868  launch_linux.py       41     DEBUG       main                           Config app-default/ntp_check value True
2020-11-01 20:44:40,869  launch_linux.py       41     DEBUG       main                           Config command-line/service_discovery_params value OrderedDict()
2020-11-01 20:44:40,870  launch_linux.py       41     DEBUG       main                           Config command-line/override_server_address value (None, None)
2020-11-01 20:44:40,870  launch_linux.py       41     DEBUG       main                           Config app-default/log_all value False
2020-11-01 20:44:40,871  launch_linux.py       41     DEBUG       main                           Config app-default/high_dpi_gui value False
2020-11-01 20:44:40,878  injector.py           805    INFO        main                           world 73716bdc-c3c7-4678-a73e-67c5ece864e3 loaded ok from /home/pi/.printnode/printnode/11/configuration.json
2020-11-01 20:44:41,089  injector.py           577    INFO        Qt                             Qt: v4.8.7, PyQt: v4.12.1, sip: v4.19.3
3
  • 2
    Create your local systemd files in /etc/systemd/system.
    – Dougie
    Commented Oct 31, 2020 at 12:47
  • Please edit your question and add the output of this command to it: cat /home/pi/Desktop/PrintNode. What is the driverobot.service?
    – Ingo
    Commented Oct 31, 2020 at 19:34
  • Added! driverbot.service was my mistake, which I corrected in my post.
    – s02e16
    Commented Oct 31, 2020 at 20:40

1 Answer 1

4

You wrote:

Program is placed in a file in desktop

and

it is supposed to work by typing ./PrintNode inside the file - which works, when I do it.

This has confused me. It seems you mean "directory" instead of "file". Then I assume, from the command line with user pi this runs successful:

rpi ~$ cd ~/Desktop/PrintNode
rpi ~$ ./PrintNode

To reflect this in a new Unit file, first delete your old service. It violates some general guidelines.

rpi ~$ sudo systemctl disable PrintNode.service
rpi ~$ sudo rm /lib/systemd/system/PrintNode.service

Then create a new service with:

rpi ~$ sudo systemctl edit --force --full PrintNode.service

In the empty editor insert these statements, save them and quit the editor:

[Unit]
Description=PrintNode Service
After=graphical.target

[Service]
User=pi
Environment=DISPLAY=:0.0
WorkingDirectory=/home/pi/Desktop/PrintNode
ExecStart=/home/pi/Desktop/PrintNode/PrintNode

[Install]
WantedBy=graphical.target

Enable the service and reboot.

9
  • Thank you for that response and I'm sorry for problem with file/directory. I've set up everything according to your information, service is running but unfortunately it did't run PrintNode client on startup. When using command /home/pi/Desktop/PrintNode/PrintNode itself in terminal it starts normally. Is it possible that I'm missing something or I misunderstood the use of services?
    – s02e16
    Commented Nov 1, 2020 at 11:45
  • @s02e16 Please edit your question and add the output of this command after a reboot to it: systemctl status PrintNode.service. Should PrintNode run always in the background as service, or should it run only once a short time and then successfully finish?
    – Ingo
    Commented Nov 1, 2020 at 11:50
  • added to original post!
    – s02e16
    Commented Nov 1, 2020 at 11:53
  • @s02e16 What does PrintNode do on the command line? Is there any output? A message on the command line? How do you stop PrintNode?
    – Ingo
    Commented Nov 1, 2020 at 11:57
  • I pasted output below. It launches GUI of PrintNode client: pi@print-server:~ $ /home/pi/Desktop/PrintNode/PrintNode 2020-11-01T13:18:57 info PrintNode v4.24.1 2020-11-01T13:18:57 info Further logs available at /home/pi/.printnode/printnode/11/logs/20201101T121857.094 2020-11-01T13:18:57 info Application starting; pi/6864 on Linux-5.4.72-v7l+-armv7l-with-debian-10.6.
    – s02e16
    Commented Nov 1, 2020 at 12:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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