cronitor
cronitor copied to clipboard
Add new state 'running'
Hey josh,
i miss on state.
Also available are ok, failed, overdue,... but not running. I use cronitor with long runtimes. it will be usefull see that cron is running.
greetings Sam
hm, I can think of a couple ways to do this. (There may be other ways I haven't thought of, just writing down my thoughts now to share.)
The easy way:
- Change
cronitor-runto send two HTTP requests -- one when the job starts, and one when it finishes. - Change
cronitor-serverto handle the "job started" request, and create a new log file / entry in the table, which is somehow marked in "running" state. - Add a timeout to
cronitor-serverto clean up any running jobs that never completed.
The downside to this is you don't get any kind of progress information or partial logs, if the job stops in the middle (e.g. due to network failure, power loss, etc.). Collecting progress information would be significantly more complicated, but probably a lot more useful for debugging purposes. So the harder way would look something like:
- Change
cronitor-runto open a WebSockets or similar session tocronitor-serverbefore starting the job. (Having a long-running HTTP POST request probably won't work, because any proxies etc. in the middle will tend to timeout pretty quickly.) - Run the job, capture the output as it is produced, and send it down the WebSocket to
cronitor-server. - Add an appropriate WebSocket (or similar) handler to
cronitor-serverwhich can incrementally update logs as they are streamed from the client, and keep track of the "running" state of each job as described in the easy way above. - Modify the UI to understand the new "running" job state and display partial logs. This might include a way to stream logs from the server as they come in (like what Jenkins does), or just show a point-in-time snapshot and periodically / manually refresh.
WebSockets is probably the right way to go here (instead of a vanilla TCP socket), to support running Cronitor behind an HTTP proxy. Unfortunately, I know very little about WebSockets (beyond that they exist and might be useful for something like this).
Also unfortunately, I'm not sure I'll have time to implement this myself in the near future. But I'd be happy to review pull requests and offer whatever suggestions I can.