webhook icon indicating copy to clipboard operation
webhook copied to clipboard

Unexpected behavior when webhook started @reboot from crontab

Open csotiistvan opened this issue 2 years ago • 2 comments

I have a weird issue when trying to automate webhook startup as part of my CI/CD workflow. Currently when webhook is started from the root crontab with either of the following options it starts and listens normally, but responds with HTTP 404 (message: Hook not found)

@reboot sudo webhook -hooks /home/ubuntu/hooks.json -hotreload &

@reboot sleep 120 && sudo webhook -hooks /home/ubuntu/hooks.json -hotreload &

When I run the exact same command manually, webhook handles the requests normally, an HTTP 200 code and the message set in the hooks.json file is received. Seems to me that when webhook is started from crontab @reboot it has no access to the hooks.json file, even though it has access right set correctly. I tried adding a time delay for starting to maybe wait for the full boot process to finish but it does not change the outcome. Changing the hooks.json on the fly has no effect either when started from crontab, but I can see the change when webhook is run manually, so the hotreload works in that case.

Any idea what causes this behavior?

csotiistvan avatar Dec 08 '22 13:12 csotiistvan

I've never used the crontab @reboot feature, but I'm almost certain this is a problem in your environment and not in webhook.

moorereason avatar Dec 09 '22 14:12 moorereason

Are the necessary environmental variables or system services on Ubuntu documented somewhere? Couldn't really find info on this in the resources and it is not super clear by just skimming the code quickly. Tried defining some env vars (like paths and default shell) before calling it from crontab but no change in the result.

For reference I'm running it under ubuntu 18.04 or later currently, the process starts and is listening on the provided port, just returns the 404 message when called if it was started by crontab. Any tips are welcome.

csotiistvan avatar Dec 09 '22 14:12 csotiistvan

I'm assuming this is a system environment issue and not a webhook issue. Closing.

moorereason avatar Apr 01 '24 21:04 moorereason