Systemd Start-Script

Started by UncleSam, May 29, 2018, 10:39:14 AM

Previous topic - Next topic

UncleSam

Hi there,
if you want you can use my start/stop script for Systemd:
1. Create a new file: /lib/systemd/system/jts3servermod.service2. Fill it like this sample:[Unit]Description=JTS3ServermodAfter=network.target[Service]
PIDFile=/path/to/JTS3ServerMod_HostingEdition/jts3servermod.pid
WorkingDirectory=/path/to/JTS3ServerMod_HostingEdition/
ExecStart=/usr/bin/java -Xms1G -Xmx2G -jar JTS3ServerMod.jar
Type=simple
Restart=always
RestartSec=15
User=botusername
Group=botgroupname

[Install]
WantedBy=multi-user.target

Description (just of some entries):

       
  • Restart always: if bot was stopped for any reasons other then 'service jts3servermod stop' or 'systemctl stop jts3servermod' it starts this service again
  • RestartSec 15: if the above happens it waits 15 seconds between crash and start
  • User: linux username the bot should run under
  • Group: optional, if not used comment it using "#" or delete it
3. enable it to auto start systemctl daemon-reload
systemctl enable jts3servermod.service

4. Have fun :-)service jts3servermod start/stop/restart
Image already added

VeLutIon

Hi, I did it exactly as you explained it. However, I get an error. Here is the mistake. Can you help me with my problem

● jts3servermod.service
   Loaded: error (Reason: Invalid argument)
   Active: inactive (dead)

Jun 06 13:33:47 VeLutIon systemd[1]: [/lib/systemd/system/jts3servermod.service:1] Unknown section 'Unit]Description=JTS3ServermodAfter=network.target[Service'. Ignoring.
Jun 06 13:33:47 VeLutIon systemd[1]: jts3servermod.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Jun 06 13:33:49 VeLutIon systemd[1]: [/lib/systemd/system/jts3servermod.service:1] Unknown section 'Unit]Description=JTS3ServermodAfter=network.target[Service'. Ignoring.
Jun 06 13:33:49 VeLutIon systemd[1]: jts3servermod.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Jun 06 13:36:37 VeLutIon systemd[1]: [/lib/systemd/system/jts3servermod.service:1] Unknown section 'Unit]Description=JTS3ServermodAfter=network.target[Service'. Ignoring.
Jun 06 13:36:37 VeLutIon systemd[1]: jts3servermod.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Jun 06 13:36:47 VeLutIon systemd[1]: [/lib/systemd/system/jts3servermod.service:1] Unknown section 'Unit]Description=JTS3ServermodAfter=network.target[Service'. Ignoring.
Jun 06 13:36:47 VeLutIon systemd[1]: jts3servermod.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Jun 06 13:36:53 VeLutIon systemd[1]: [/lib/systemd/system/jts3servermod.service:1] Unknown section 'Unit]Description=JTS3ServermodAfter=network.target[Service'. Ignoring.
Jun 06 13:36:53 VeLutIon systemd[1]: jts3servermod.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.