I was looking into setting up my own incoming webhook server, because webhooks are super cool and useful for a variety of things.
And also because I am a giant nerd and wanted to play around with some stuff.
Now, there are very few ready made components for this out there, so I had to do a bit of digging and I've ended up with the configuration I'm documenting here for posterity.
My setup is running on a VM on my local network, and I've routed an obscure port to it, so I can receive webhook requests from anywhere on the internet.
The setup is as follows:
- a VM running Ubuntu 16.04.3
- Adnan Hajdarević's awesome Webhook server written in Go.
Setting up Go
Go is not in Ubuntus repos yet (should be in 17.04, but that does not have LTS support). So I followed these excellent instructions.
Running the program as a service
First I install the webhook server.
go get github.com/adnanh/webhook
This has no real value if I have to log in to the server and manually start it after each reboot, so with a little help from Caius I managed to set it up as a service, so the webhook runs on each boot.
ExecStart=/home/[username]/work/bin/webhook -hooks /var/webhook/config/hooks.json -verbose
# make sure log directory exists and owned by syslog
ExecStartPre=/bin/mkdir -p /var/log/echoservice
ExecStartPre=/bin/chown syslog:adm /var/log/echoservice
ExecStartPre=/bin/chmod 755 /var/log/echoservice
The program loads a config file called hooks.json, that I've placed in /var/webhook/config, and it's a basic file that lists the names of the hooks available, what script that hook should activate and what the working directory for that command is.
Now I can define what hooks I want, and whatever scripts I need to have executed. Examples of this could be having my Hue lights flash if one of my servers crash, or privately scrobbling my Plex views, to name but a few things I can do with this little box.