mirror of
https://github.com/FAUSheppy/systemd-socket-activation-template
synced 2025-12-06 06:51:35 +01:00
Initial
This commit is contained in:
1
LICENSE
Normal file
1
LICENSE
Normal file
@@ -0,0 +1 @@
|
|||||||
|
This work does not have the required threshold of originality to be considered for copyright it should therefore be considered to be in the Public Domain.
|
||||||
4
example-check-stop.sh
Normal file
4
example-check-stop.sh
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# if condition
|
||||||
|
systemctl stop example.sevice
|
||||||
6
example-deactivate-check.service
Normal file
6
example-deactivate-check.service
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Check if unit example.service should be stopped.
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/absolute/path/to/example-check-stop.sh
|
||||||
10
example-deactivate-check.timer
Normal file
10
example-deactivate-check.timer
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Continiously check if example.service should be stopped
|
||||||
|
After=example.service
|
||||||
|
PartOf=example.service
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnUnitActiveSec=15min
|
||||||
|
OnActiveSec=14min
|
||||||
|
Persistent=false
|
||||||
|
Unit=sheppy-minecraft-autodeactivate.service
|
||||||
10
example-socket-proxy.service
Normal file
10
example-socket-proxy.service
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=socket proxy example.service
|
||||||
|
After=example.service
|
||||||
|
Requires=example.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/lib/systemd/systemd-socket-proxyd 127.0.0.1:PORT_NUMBER_HERE
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
32
example.service
Normal file
32
example.service
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=minecraft server
|
||||||
|
After=network.target
|
||||||
|
Requires=sheppy-minecraft-autodeactivate.timer
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
User=minecraft
|
||||||
|
WorkingDirectory=/home/minecraft/server/
|
||||||
|
Nice=2
|
||||||
|
CPUAffinity=0,3
|
||||||
|
|
||||||
|
## exit status of mcrcon on success, 143 ist SIGTERM in java, the default for mc
|
||||||
|
SuccessExitStatus=2 3 143 255
|
||||||
|
|
||||||
|
ExecStart=/absolute/path/to/example.sh
|
||||||
|
ExecStop=pkill example.sh
|
||||||
|
|
||||||
|
TimeoutStopSec=30
|
||||||
|
Restart=always
|
||||||
|
RestartSec=60
|
||||||
|
|
||||||
|
## RES CONTROL ##
|
||||||
|
MemoryLow=2G
|
||||||
|
MemoryHigh=4G
|
||||||
|
## Java VM Limit is 4GB so this should never happen ##
|
||||||
|
MemoryMax=6G
|
||||||
|
CPUQuota=100%
|
||||||
|
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
2
example.sh
Normal file
2
example.sh
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
sleep 600
|
||||||
11
example.socket
Normal file
11
example.socket
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Socket Activator for example.service
|
||||||
|
PartOf=example-proxy.service
|
||||||
|
|
||||||
|
[Socket]
|
||||||
|
ListenStream=PORT_NUMBER_HERE
|
||||||
|
BindIPv6Only=both
|
||||||
|
Accept=false
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
Reference in New Issue
Block a user