Failed to restart octoprint.service: Unit octoprint.service not found

Hi,
I have installed Octoprint 1.4.0.
System spec:
Operating System: Ubuntu 16.04.6 LTS
Kernel: Linux 3.4.39-BPI-M3-Kernel
Architecture: arm

Tu run OctoPrint I use virtualenv -> octoprint serve. And it work fine. The problem is I'm not able to restart octoprint. From Octoprint interface under pop up notification it says it was done successfully but acctually it's not a truth. In terminal it ask for password and after it crashes. I was trying to go through :

but it doesn't seams to be my issue.

Runing sudo service octoprint restart command directly into terminal it returns me an error :
Failed to restart octoprint.service: Unit octoprint.service not found.

How to force Octoprint to restart itself on demand?

You need to add the systemd unit files for the service and likely configure sudo rights to allow the user to run the restart command.

1 Like

Sudo rights:
sudo nano /etc/sudoers.d/pi-nopasswd // added following text to file which was empty in my case

pi ALL=NOPASSWD: ALL

Next I copied files from downloaded source:

sudo cp ~/octoprint/Octoprint/scripts/octoprint.init /etc/init.d/octoprint

sudo chmod +x /etc/init.d/octoprint

sudo cp ~/octoprint/Octoprint/scripts/octoprint.default /etc/default/octoprint

sudo cp ~/octoprint/Octoprint/scripts/octoprint.service /etc/systemd/system/octoprint.service

Now I'm able to use proper commands like :

  • Restart OctoPrint: sudo service octoprint restart
  • Restart system: sudo shutdown -r now
  • Shutdown system: sudo shutdown -h now

And my Octoprint starts automatically :slight_smile: I'm not sure if that's impemented in newest version or it's because I was working some time on that also.. Anyway I'm really happy with current state.

One more time big THANK YOU kantlivelong !!!!!!

Glad you got it worked out :+1:

Though I would reduce the rights for the user pi w/ sudo.

As a reference this is what OctoPi uses.