Advertisement
Wrong_Beaver

minecraft@.service v2

Jun 12th, 2022
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.88 KB | None | 0 0
  1. [Unit]
  2. Description=Minecraft Server %i
  3. After=network.target
  4.  
  5. [Service]
  6. WorkingDirectory=/opt/minecraft/mc_servers/%i
  7.  
  8. # Solves the issue where the minecraft server will endlessly restart itself
  9. # See https://askubuntu.com/questions/953920/systemctl-service-timed-out-during-start for more info
  10. Type=simple
  11.  
  12. PrivateUsers=true
  13. # Users Database is not available from within the unit, only root and minecraft is available, everybody else is nobody
  14.  
  15. User=minecraft
  16. Group=minecraft
  17.  
  18. ProtectSystem=full
  19. # Read only mapping of /usr /boot and /etc
  20.  
  21. ProtectHome=true
  22. # /home, /root and /run/user seem to be empty from within the unit. It is recommended to enable this setting for all long-running services (in particular network-facing ones).
  23.  
  24. ProtectKernelTunables=true
  25. # /proc/sys, /sys, /proc/sysrq-trigger, /proc/latency_stats, /proc/acpi, /proc/timer_stats, /proc/fs and /proc/irq will be read-only within the unit. It is recommended to turn this on for most services.
  26. # Implies MountFlags=slave
  27.  
  28. ProtectKernelModules=true
  29. # Block module system calls, also /usr/lib/modules. It is recommended to turn this on for most services that do not need special file systems or extra kernel modules to work
  30. # Implies NoNewPrivileges=yes
  31.  
  32. ProtectControlGroups=true
  33. # It is hence recommended to turn this on for most services.
  34. # Implies MountAPIVFS=yes
  35.  
  36. # Set default memory values
  37. #Environment="MCMINMEM=512M" "MCMAXMEM=1024M"
  38. #Enviroment="SHUTDOWN_DELAY=5" "POST_SHUTDOWN_DELAY=10"
  39. # Change memory values in environment file
  40. #EnvironmentFile=-/opt/minecraft/%i/server.conf
  41.  
  42. # Uncomment this to fix screen on RHEL 8
  43. #ExecStartPre=+/bin/sh -c 'chmod 777 /run/screen'
  44.  
  45. #ExecStart=/bin/sh -c '/opt/minecraft/mc_servers/server_controll/start_server %i'
  46.  
  47. #ExecStop=/opt/minecraft/mc_servers/server_controll/stop_server %i
  48.  
  49. Restart=on-failure
  50. RestartSec=60s
  51.  
  52. [Install]
  53. WantedBy=multi-user.target
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement