frappe / bench

CLI to manage Multi-tenant deployments for Frappe apps
https://frappeframework.com/docs/user/en/bench
GNU General Public License v3.0
1.36k stars 1.19k forks source link

feat: bench stop #1570

Open phot0n opened 2 months ago

phot0n commented 2 months ago

When we abruptly close a terminal window, all the processes spawned via bench start remain running in the background which upon invoking bench start again gives "address already in use" error and fails to spawn.

Gitlab also faced this and they added another service which knows/monitors all the other spawned processes and allows users to stop the process (via a stop command (eg: bench stop)) before trying to start the services again (ref: https://gitlab.com/gitlab-org/gitlab-development-kit/-/blob/main/doc/runit.md?ref_type=heads#why-replace-foreman). Maybe we could try something similar?

ps aux | grep -e $(bench pwd) -e $(bench get-redis-ports) and then killing those processes might do but feels very hacky. Maybe if we keep the process pids somewhere we can then directly kill them when invoking bench stop command?

Maybe we can add signal handler in honcho to handle SIGHUP? which will cause all processes to exit as soon as terminal is closed.

Any/all thoughts are welcome :)

auliabismar commented 3 weeks ago

been using this tool