Skip to content

Instantly share code, notes, and snippets.

@sj26
Created May 27, 2016 04:57
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save sj26/bccfac9142bf804113b4c1f4026d105a to your computer and use it in GitHub Desktop.
Starting multiple buildkite-agents per-machine with systemd
[Unit]
Description=Buildkite Agents
Documentation=https://buildkite.com/agent
Wants=buildkite-agent@1.service
Wants=buildkite-agent@2.service
# ...
[Service]
Type=oneshot
ExecStart=/bin/true
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
[Unit]
Description=Buildkite Agent %i
Documentation=https://buildkite.com/agent
BindsTo=buildkite-agent.service
After=syslog.target
After=network.target
[Service]
Type=simple
User=buildkite-agent
Environment=HOME=/var/lib/buildkite-agent
SyslogIdentifier=buildkite-agent-%i
ExecStart=/usr/bin/buildkite-agent start --name="%H-%i"
ReloadPropogatedFrom=buildkite-agent.service
RestartSec=5
Restart=on-failure
TimeoutSec=10
@sj26
Copy link
Author

sj26 commented May 27, 2016

$ sudo systemctl status buildkite-agent.service
● buildkite-agent.service - Buildkite Agents
   Loaded: loaded (/etc/systemd/system/buildkite-agent.service; enabled; vendor preset: enabled)
   Active: active (exited) since Fri 2016-05-27 04:54:30 UTC; 3min 15s ago
     Docs: https://buildkite.com/agent
  Process: 14439 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
 Main PID: 14439 (code=exited, status=0/SUCCESS)

May 27 04:54:30 buildkite-foo systemd[1]: Starting Buildkite Agent...
May 27 04:54:30 buildkite-foo systemd[1]: Started Buildkite Agent.

$ sudo systemctl status buildkite-agent@1.service
● buildkite-agent@1.service - Buildkite Agent 1
   Loaded: loaded (/etc/systemd/system/buildkite-agent@.service; static; vendor preset: enabled)
   Active: active (running) since Fri 2016-05-27 04:54:30 UTC; 3min 47s ago
     Docs: https://buildkite.com/agent
 Main PID: 14438 (buildkite-agent)
   CGroup: /system.slice/system-buildkite\x2dagent.slice/buildkite-agent@1.service
           └─14438 buildkite-agent v2.2-beta.1 [idle]

May 27 04:54:30 buildkite-foo systemd[1]: Started Buildkite Agent 1.
May 27 04:54:31 buildkite-foo buildkite-agent-1[14438]: _           _ _     _ _    _ _                                _
May 27 04:54:31 buildkite-foo buildkite-agent-1[14438]: | |         (_) |   | | |  (_) |                              | |
May 27 04:54:31 buildkite-foo buildkite-agent-1[14438]: | |__  _   _ _| | __| | | ___| |_ ___    __ _  __ _  ___ _ __ | |_
May 27 04:54:31 buildkite-foo buildkite-agent-1[14438]: | '_ \| | | | | |/ _` | |/ / | __/ _ \  / _` |/ _` |/ _ \ '_ \| __|
May 27 04:54:31 buildkite-foo buildkite-agent-1[14438]: | |_) | |_| | | | (_| |   <| | ||  __/ | (_| | (_| |  __/ | | | |_
May 27 04:54:31 buildkite-foo buildkite-agent-1[14438]: |_.__/ \__,_|_|_|\__,_|_|\_\_|\__\___|  \__,_|\__, |\___|_| |_|\__|
May 27 04:54:31 buildkite-foo buildkite-agent-1[14438]:                                                __/ |
May 27 04:54:31 buildkite-foo buildkite-agent-1[14438]: http://buildkite.com/agent                    |___/
May 27 04:54:31 buildkite-foo buildkite-agent-1[14438]: 2016-05-27 04:54:31 NOTICE Starting buildkite-agent v2.2-beta.1 with PID: 14438
May 27 04:54:31 buildkite-foo buildkite-agent-1[14438]: 2016-05-27 04:54:31 NOTICE The agent source code can be found here: https://github.com/buildkite/agent
May 27 04:54:31 buildkite-foo buildkite-agent-1[14438]: 2016-05-27 04:54:31 NOTICE For questions and support, email us at: hello@buildkite.com
May 27 04:54:31 buildkite-foo buildkite-agent-1[14438]: 2016-05-27 04:54:31 INFO   Configuration loaded from: /etc/buildkite-agent/buildkite-agent.cfg
May 27 04:54:31 buildkite-foo buildkite-agent-1[14438]: 2016-05-27 04:54:31 INFO   Registering agent with Buildkite...
May 27 04:54:32 buildkite-foo buildkite-agent-1[14438]: 2016-05-27 04:54:32 INFO   Successfully registered agent "buildkite-foo-1" with meta-data [queue=default]
May 27 04:54:32 buildkite-foo buildkite-agent-1[14438]: 2016-05-27 04:54:32 INFO   Connecting to Buildkite...
May 27 04:54:32 buildkite-foo buildkite-agent-1[14438]: 2016-05-27 04:54:32 INFO   Agent successfully connected
May 27 04:54:32 buildkite-foo buildkite-agent-1[14438]: 2016-05-27 04:54:32 INFO   You can press Ctrl-C to stop the agent
May 27 04:54:32 buildkite-foo buildkite-agent-1[14438]: 2016-05-27 04:54:32 INFO   Waiting for work...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment