Restart commands for MACOS

What is the problem?
I have setup Octoprint on my Mac mini running MacOS1.15.5.
Got all running and connected. On rebooting my Mac I am now stuck in safe mode.

What did you already try to solve it?
I have tried adding the commands:
sudo service octoprint restart
sudo -A service octoprint restart
sudo -S service octoprint restart
From the logs I need to input password to restart. How do I configure this?

From the looks of it
sudo -S service octoprint restart was the closest but want a password. -A I don have an ask pass program.

Logs
2! STDERR: sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
2020-06-12 10:49:58,548 - octoprint.server.heartbeat - INFO - Server heartbeat <3
2020-06-12 10:50:29,197 - octoprint.server.api.system - INFO - Performing command for core:restart: sudo -S service octoprint restart
2020-06-12 10:50:29,383 - octoprint.server.api.system - WARNING - Command for core:restart failed with return code 1:
! STDOUT:
! STDERR: Password:
! sudo: no password was provided
2020-06-12 10:51:58,909 - octoprint.server.api.system - INFO - Performing command for core:restart: sudo -A service octoprint restart
2020-06-12 10:51:58,991 - octoprint.server.api.system - WARNING - Command for core:restart failed with return code 1:
! STDOUT:
! STDERR: sudo: no askpass program specified, try setting SUDO_ASKPASS

I have found a solution of manually rebooting my Mac each time, wonder if there is a simpler way of just restarting the service some how?

Hi,

Any solution for restart octoprint without system reboot on MacOSX?

Thanks

the only solution I have found is stopping the terminal window and reopening with Serve Octoprint etc

Hi,

can u give me the exact codes for doing this?

I could not understand what u mean.

Thanks

What they mean was stopping it manually, by closing the window that they run the octoprint serve command.

ok, i install octoprint from this guide
https://community.octoprint.org/t/setting-up-octoprint-on-macos/

as a service.

So i don't have a running terminal window for octoprint server.

Can i terminate octoprint server from osx activity monitor ? what is the process id ? or any other solution ?

i understand to start with octoprint serve command but first of all i need to terminate the server...

Hi,

I have made a shell script with macos automator; Code is;

killall Python
sleep 3
launchctl load /Library/LaunchDaemons/it.username.octoprint.plist

I use https://community.octoprint.org/t/setting-up-octoprint-on-macos/ guide for auto start on boot as a service.

so you need to change "it.username.octoprint.plist" file name to yours.

This script kills octoprint server and restart it. I made a script shortcut to my desktop.

Everything works now...

1 Like

Thanks digitalcan!!!! I recently went through the installation and did the same setup as you, but also struggled with getting the server to restart. One solution I found IF the server is started in Terminal was to use

kill -9 $(jobs -p)

This command worked great to stop the job and then the normal commands to restart everything, but if the autostart script (it.YOURNAME.octoprint.plist) is used terminal won't work. So I used your method to use Automator to make that shell script. Then dumped the script in my octoprint directory (~/OctoPrint/opRestart.app). In the Octoprint server setting command line for Restart Octoprint, i added:

open ~/OctoPrint/opRestart.app

Now the restart menu option works!

Hi,

I wasn't happy with the killall Python command, so I came up with this command to kill the exact octoprint process:

kill $(ps -A | grep -v "grep" | grep "venv/bin/octoprint" | awk '{print $1}')

This command will only kill the process.
In order to start it again, if you've followed the community guide to install it on macos and auto-start it on boot, you should just edit the .plist file again and change KeepAlive to true and LaunchOnlyOnce to false.

With this change the process will be re-spawned automatically by launchd.

Hope it helps!

1 Like