Posts Configure Services as Systemd Service
Post
Cancel

Configure Services as Systemd Service


Goal:

Configure services to be managed by Systemd using systemctl command

briefting:

Explanation from man systemctl

systemctl may be used to introspect and control the state of the “systemd” system and service manager. Please refer to systemd(1) for an introduction into the basic concepts and functionality this tool manages.

Location of configuration files is at /user/lib/systemd/system systemctl

Where when enable the service through systemctl command, a soft link will be created at /etc/systemd/system/multi-user.target.wants systemctl

The purpose of this post is to record down the systemd configuration files made for Prometheus, alertmanager, nginx-exporter etc

***

Prometheus

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[Unit]
Description=prometheus
After=network.target

[Service]
Type=simple
#ExecStart=/opt/prometheus/prometheus --web.enable-admin-api --config.file=/opt/prometheus/prometheus.yml
ExecStart=/opt/prometheus/prometheus --config.file=/opt/prometheus/prometheus.yml
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
Restart=on-failure

[Install]
WantedBy=multi-user.target

Nginx Exporter

1
2
3
4
5
6
7
8
9
10
11
[Unit]
Description=NGINX Prometheus Exporter
After=network.target

[Service]
Type=simple
ExecStart=/opt/nginx-prometheus-exporter
Restart=always

[Install]
WantedBy=multi-user.target

Alertmanager

1
2
3
4
5
6
7
8
9
10
11
12
13
[Unit]
Description=alertmanager
After=network.target

[Service]
Type=simple
ExecStart=/opt/alertmanager/alertmanager --config.file=/opt/alertmanager/alertmanager.yml
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
Restart=on-failure

[Install]
WantedBy=multi-user.target
This post is licensed under CC BY 4.0 by the author.