How do i stop an agent using CLI

I am trying to stop my client agent in order to restart with an updated hcl file. The only way I know to end the agent is using Ctrl^C, however I have since closed that terminal page. I am looking for a method to kill the agent from anywhere in the vm or restart the agent with the updated file.

I was able to reset the agent by manually rebooting my linode. I then was able to start both the server and clients agents. However, I don’t think this is the idea solution.

The Nomad client and server agents can be configured by an init system like systemd that should allow you to restart the agent. Here is an example of a systemd file for a Nomad client.

ExecStart=/usr/local/bin/nomad agent -config /etc/nomad
ExecReload=/bin/kill -HUP $MAINPID

You can create a service file /etc/systemd/system/nomad.service

I assume once the file is present I can issue a command like systemd restart nomad?

Yes, if you have systemd installed then you should be able to run systemctl restart nomad.

Note: The service file is just an example. You can customize it as needed for your use case.

A more comprehensive systemd unit can be found in the Nomad repository. Installing Nomad from package will also install a systemd unit for you automatically.

Hope this helps!
Charlie Voiselle
Product Education Engineer, Nomad

1 Like