thijsvanloef / palworld-server-docker

A Docker Container to easily run a Palworld dedicated server.
https://hub.docker.com/r/thijsvanloef/palworld-server-docker
MIT License
2.43k stars 296 forks source link

Daily/weekly restart #37

Closed GMBridge closed 9 months ago

GMBridge commented 9 months ago

since there's guaranteed to be memory leaks in their server client, can we get a ENV values to manage restarts (daily, weekly, what time of day, etc). longer term if they provide more logging from the server binary, being able to skip the restart if players are connected would be cool.

thijsvanloef commented 9 months ago

This is something that is not in the scope of this project. There are also a lot of ways this can be achieved without changing the current image.

You might want to try running a restarter container next to the server like this:

services:
   palworld:
      image: thijsvanloef/palworld-server-docker:latest
      restart: unless-stopped
      container_name: palworld-server
      ports:
        - 8211:8211/udp
        - 27015:27015/udp
      environment:
         - PUID=1000
         - PGID=1000
         - PORT=8211 # Optional but recommended
         - PLAYERS=16 # Optional but recommended
         - MULTITHREADING=false
         - COMMUNITY=false  # Enable this if you want your server to show up in the community servers tab, USE WITH SERVER_PASSWORD!
         # Enable the environment variables below if you have COMMUNITY=true
         # - SERVER_PASSWORD="worldofpals"
         # - SERVER_NAME="World of Pals"
         # - ADMIN_PASSWORD="someAdminPassword"
      volumes:
         - ./palworld:/palworld/
   restarter:
      image: docker:cli
      volumes: ["/var/run/docker.sock:/var/run/docker.sock"]
      command: ["/bin/sh", "-c", "while true; do sleep 86400; docker restart palworld-server; done"]
      restart: unless-stopped

Or creating a cron job that restarts the container daily:

0 0 * * * docker compose -f <your/compose/file> restart  >/dev/null 2>&1
Okynawah commented 9 months ago

Not tested but it should be docker restart palworld-server instead of docker restart palworld