Running shell script causes web interface to stop responding #173
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I created a Shell Script output that runs the filament motion sensor script in issue #122. That script generates output to stdout, which is captured in some way by the Enclosure Plugin, and displayed when the script exits. This particular shell script runs for the duration of the print, and it seems that while the Enclosure Plugin is capturing stdout from the script, it causes the OctoPrint web interface to stop accepting connections.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The web interface should continue accepting connections.
Additional context
I didn't have debug enabled, and the printer is in the middle of a large print. Once it's done, I will do further testing and get a log file.
That is not an issue, it's by design, the plugin expects the script to run and return a value so it knows that it was executed. If your script blocks or runs for longer you may want to execute it on the background punting an "&" on the end of the command line.
sudo FilamentMonitor.sh &However keep in mind that the enclosure plugin will not be able to communicate with the executing program after you tell it to run. So it will not know when the print finishes.
The correct way to implement what you are trying to do is to create a daemon (service) with your code, and make that daemon accept commands from the bash, so you will always have a "filament monitor" service running on your pi, and you would for example accept commands like
filamentmonitor start,filamentmonitor stopetc.......or convert it to Python like you've requested, so it would be easier to implement in a plugin. :/
yes, or that! =P