Installation d'un service sous Linux

Installation d'un service sous Linux

Exemple de configuration pour lancer un service sous Linux

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
[Unit]
Description=Mon service server daemon
After=network.target

[Service]
#Type=simple
#Type=exec
Type=forking
EnvironmentFile=/etc/sysconfig/monservice
ExecStart=/usr/sbin/monservice
#Restart= always
User=monuser
KillMode=process
Environment=MON_SERVICE_HOME=/usr/share/monservice
Environment=MON_SERVICE_CONF=/etc/monservice/conf
Environment=LOCAL_JMX=false

[Install]
WantedBy=multi-user.target

Ensuite pour l’installer :

1
2
3
4
5
6
7
8
# installer
sudo cp curator/mon-service.service /etc/systemd/system/mon-service.service
sudo systemctl enable mon-service.service
sudo systemctl start mon-service.service
# voir l'état
sudo systemctl status mon-service.service
# voir les logs
journalctl -u mon-service.service

Pour la commande pour lancer le processus

1
2
3
#!/bin/bash

nohup java -jar /home/monservice/mon-service-webapp-1.0.0-SNAPSHOT.jar --spring.config.location=/home/monservice/config/application.yml > /dev/null 2>&1 &
Généré avec Hugo
Thème Stack conçu par Jimmy