I am setting up a webhook in a VPS so it gets pulls the code from a git repository every time there is a new commit. I have managed to set it up but it only works while -hooks
is running.
After creating the webhook I use the following command to start listening (Replacing 0.0.0.0 with the actual public IP address of the VPS):
/usr/bin/webhook -hooks /root/webhooks/hooks.json -ip "0.0.0.0" -verbose
Then I get the following output:
[webhook] 2022/12/28 07:47:03 version 2.5.0 starting
[webhook] 2022/12/28 07:47:03 setting up os signal watcher
[webhook] 2022/12/28 07:47:03 attempting to load hooks from /root/webhooks/hooks.json
[webhook] 2022/12/28 07:47:03 found 1 hook(s) in file
[webhook] 2022/12/28 07:47:03 loaded: my-site.com
[webhook] 2022/12/28 07:47:03 serving hooks on http://0.0.0.0:9000/hooks/{id}
[webhook] 2022/12/28 07:47:03 os signal watcher ready
And I have configured the webhook in GitHub
:
http://0.0.0.0:9000/hooks/my-site.com
The webhook works properly as long as [webhook] 2022/12/28 07:47:03 os signal watcher ready
is on the screen, but if I press Ctrl + C
then it is interrupted and the webhook is no longer listening.
Is there a way to keep the webhook listening in the background, so that any time there is a new commit on GitHub
the VPS gets the latest code?