Simple Deployment Agent

Published on 17 Dec 2017


This post is mainly about a project which I carried out to achieve following simple tasks.

To carry out these tasks the project has a listener which listens for a webhook called from a CI server once the updated code is tested and can be deployed. After the webhook, it executes the configured scripts or commands with arguments on the server which can be used to download a file (archive) from cloud and deploy to app server.


The usage is really straight forward, initialize, add configurations, modify it (currently by editing config file) and start listener. For a common use case following are steps.

Get the binary

Initialize and add a new configuration ➕


deployment-agent init

Adding a configuration

Configuration contains following things.

Following is a sample command to run for adding a project configuration.

deployment-agent add --name name \
    --work-dir work/dir/location \
    --hook /script/hook.sh \
    --ip-cidr # To allow
    # to IPs

This will return two things which are necessary for the accessing the listener.

UUID for this project is: ece419ae-8ee2-44e3-a0d3-589eae79cd27
Hash to be used for Cgcf012PIoTAx9lG93N7qHg_Cg9qYM_g_TMjh690xGDS

Serving 🍽

This part is mainly to start the server which listens for webhook.

It can be configured by changing the host/port in configuration file.

Serve command comes with an option to detect change in project configurations by appending --watch-config.

deployment-agent serve --watch-config

This should start a server listening.


Once the server starts listening, there is a route /reload for running the hooks on remote server.

Following is a sample cURL for the same.

curl -i https://localhost:8080/reload/ece419ae-8ee2-44e3-a0d3-589eae79cd27/Cgcf012PIoTAx9lG93N7qHg_Cg9qYM_g_TMjh690xGDS

One can use following systemd file if needed to serve in background using Systemd.

Description=Deployment Agent Listener

ExecStart=/home/$USERNAME/bin/deployment-agent serve --watch-config


Replace the text $USERNAME with your username and copy it to user folder of systemd configurations. For my Debian system it works in ~/.config/systemd/user/ you can also use /etc/systemd/user/. Then do reload systemd configurations and start server followed by checking status.

systemctl --user daemon-reload
systemctl --user start deployment-agent.service
systemctl --user status deployment-agent.service

Future work

Last Updated on: 06 Jan 2018