nunofgs / docker-octoprint

Dockerfile to set up Octoprint with x86, armv6, armv7 and arm64 support!
https://hub.docker.com/r/nunofgs/octoprint/
GNU Affero General Public License v3.0
58 stars 32 forks source link

Permit users to restart octoprint easily from the web gui #30

Closed rueckix closed 5 years ago

rueckix commented 5 years ago

add autorestart to [program:octoprint] so that supervisord will re-spawn octoprint automatically even if it exits with code 0

This will allow users to configure the octoprint restart command to be "killall octoprint"

nunofgs commented 5 years ago

🤔 this one is tricky. While I really do appreciate the time and effort put into a PR, this changes a behavior that was very much intentional.

The Docker docs mention that when your process dies, the container should die with it. Indeed, pretty much every container I've tried follows this rule and leaves restarting to some orchestration service.

Personally I use docker-compose on my raspberry-pi and simply set it to autorestart there. Here's my actual docker-compose.yml in its entirety:

octoprint:
  image: nunofgs/octoprint:1.3.11
  restart: always
  privileged: true
  environment:
    STREAMER_FLAGS: '-r 1280x720'
  ports:
    - 80:80
  volumes:
    - /opt/octoprint:/data

With the restart: always your initial use-case would still work (killall octoprint).

But I think a better alternative is to simply use supervisorctl in the container to start octoprint. I just tested this scenario and works beautifully. Here's an example octoprint config.yaml:

system:
  actions:
  - action: restart
    command: supervisorctl restart octoprint
    name: Restart Octoprint

Love the contribution though. Don't get discouraged 🙏

rueckix commented 5 years ago

No worries, killing octoprint did not end the container (other processes were still running). Hence, my proposal. Doing the same with supervisorctl is even cleaner. Thanks for the hint.