Package: releasemon
ReleasemonSupervisor plugin to watch a build version file and restart programs on updateOverviewReleasemon is designed to actively monitor a known version file for changes, and if an update occurs restart supervisor managed programs.It was specifically written to restart Laravel queues on deployment whenthe contentsof a known version or timestamp file has changed.Originally inspired by Tim Schumacher's superfsmon script, releasemon is optimized to restart applications only when a specific file is seen to have updates made to its contents. This is more resource friendly as it won't keep file notification handles open for every file in a given directory (e.g all your repository source files) which can cause inotify limits to be hit on large filesystems. Notably, simply updating the timestamp (e.g. through an rsync) will NOT force restart, meaning you can limit restarts based on explicit file updates and not through unreleated filesystem changes.realeasmon also adds some new functionality such as random offsets on restart times (which can be useful for distributing load spikes).Specifically, releasemon will:Monitor a given version file on the filesystemIf a change is detected, it will re-read the version and see if it has been updatedIf it has, it will restart the supervisor programs or groups as requiredIn addition, releasemon will:Allow for pre-restart and post-restart scripts to be executedAllow only 'RUNNING' processes to restart (to avoid multiple restarts on STARTING processes)Limit the number of files being monitored to only one (limiting inotify resources needed)Releasemon uses Supervisor's XML-RPC API. Yoursupervisord.conffile must have a valid[unix_http_server]or[inet_http_server]section and a[rpcinterface:supervisor]section.
If you are able to control your Supervisor instance withsupervisorctl, you
have already have this coonigured.To restart your Laravel worker when the contents of/appdir/.versionis updated,
yoursupervisord.confmight look like this.[program:laravel-worker]
command=php /home/forge/app.com/artisan queue:work sqs --sleep=3 --tries=3 --max-time=3600

[program:releasemon]
command=releasemon /appdir/.version laravel-workerYou can use multiple instances of Releasemon to control different programs.InstallationPython 2 and 3pip install releasemonCommand Line Argumentsusage: releasemon [-h] [-e FLAG] [--disable [FLAG]]
                  [-rd SECONDS] [-fd SECONDS] [--running-only] 
                   [-g GROUP] [-a]
                  PATH [PROG [PROG ...]]

Supervisor plugin to watch a directory and restart programs on changes

optional arguments:
  -h, --help            show this help message and exit
  -e FLAG, --enable FLAG
                        disable functionality if flag is not set
  --disable [FLAG]      disable functionality if flag is set
  -rd, --random-delay   random delay in seconds prior to restarting after version change
  -fd, --fixed-delay    fixed delay in seconds prior to restarting after version change

additional tasks:
  -pre, --pre-restart   system command to run prior to restarting programs
  -post, --post-restart system command to run after restarting programs
  
directory monitoring:
  FILEPATH              full path to version file to watch for changes
        
programs:
  PROG                  supervisor program name to restart
  -g GROUP, --group GROUP
                        supervisor group name to restart
  -a, --any             restart any child of this supervisorExamplesThe following examples assume you make updates to the file/appdir/.versionon each release:Restart Supervisor program 'app':[program:releasemon]
command=releasemon /appdir/.version appRestart Supervisor program 'app' then run a post-update script:[program:releasemon]
command=releasemon --pre-restart "echo 'POST ROTATE SCRIPT'" /appdir/.version appRestart all Supervisor programs in theworkersgroup after 10 seconds:[program:releasemon]
command=releasemon --fixed-delay 10 -g workers /appdir/.versionRestart all Supervisor programs in theworkersgroup after a random delay between 0 and 60 seconds:[program:releasemon]
command=releasemon --random-delay 60 -g workers /appdir/.versionRestart all Supervisor programs[program:releasemon]
command=releasemon -a /appdir/.version appDisable functionality using an environment variable:[program:releasemon]
command=releasemon /appdir/.version app1 -e %(ENV_CELERY_AUTORELOAD)sKnown IssuesInspired bySuperfsmon by Tim Schumacherhttps://github.com/timakro/superfsmonLicenseCopyright (C) 2019 James CundleLicense GPLv3+: GNU GPL version 3 or laterhttp://gnu.org/licenses/gpl.html.This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent per‐mitted by law.