The httpcats.systemd.service
File¶
Filename | Location | Group | Project/Repository |
---|---|---|---|
httpcats.systemd.service | ./files/httpcats.systemd.service | configuration | ansible |
Why?¶
With our binary present on the remote servers we need to set up a service that runs that binary so that we can serve our static images. We'll use systemd
as it's what ships with most Linux distributions in this day and age.
All we have to do is upload a pre-configured systemd
configuration file which tells systemd
how our service is to be executed and managed.
Breakdown¶
First we configure this "unit":
1 2 3 |
|
We're supplying a description for our service so that it's clear what it is when it's displayed in the output of various systemd
tools, like systemctl
. The After
property determines WHEN the service is started. We need to start after the networking and auditing stacks have started.
Next we configure the service itself:
1 2 3 4 5 |
|
Most of the properties we're configuring here are obvious: what to run and where to run it.
Finally we tell systemd
how-to "install" the service into its database:
1 2 |
|
The Solution¶
1 2 3 4 5 6 7 8 9 10 11 12 |
|
Committing the Code¶
- Set your working directory to the
configuration/ansible
repository - Save the file as
httpcats.systemd.service
and usegit add httpcats.systemd.service
to add it to the Git staging area - Use
git commit -am 'ensuring we can manage our app via systemd'
to commit the file to our repository - Push the code to GitLab.com:
git push