mbround18 / valheim-docker

Valheim Docker powered by Odin. The Valheim dedicated gameserver manager which is designed with resiliency in mind by providing automatic updates, world backup support, and a user friendly cli interface.
https://hub.docker.com/r/mbround18/valheim
BSD 3-Clause "New" or "Revised" License
770 stars 82 forks source link

World save is not triggered on container stop #732

Closed guyspr closed 1 year ago

guyspr commented 1 year ago

I've noticed that, when restarting/stopping the server running this docker container. Then the world is not saved, and any built object will disappear since last save (which can be 30 minutes ago). It seems like the shutdown process does not force a world save which can cause data-loss.

mbround18 commented 1 year ago

@guyspr this has been resolved before, please add this to your docker compose for the service

stop_grace_period: 2m

if it still occurs consider expanding the stop_grace_period. Larger worlds will take longer to save.

guyspr commented 1 year ago

@guyspr this has been resolved before, please add this to your docker compose for the service

stop_grace_period: 2m

if it still occurs consider expanding the stop_grace_period. Larger worlds will take longer to save.

Thanks for your reply, I will be testing if this resolved the issue for me :)

mbround18 commented 1 year ago

any updates @guyspr ?

guyspr commented 1 year ago

@mbround18 It still doesn't seem to trigger the save on shutdown with the added setting. I test it by building something new in the world, then stopping and starting the container. The placed item will disappear. I do make sure to do a manual save now (using the console) before shutting down.

mbround18 commented 1 year ago

Can you drop your docker-compose? Omitting any passwords ofc

guyspr commented 1 year ago

Here's the compose file I'm using:

version: "3"
services:
  valheim:
    image: mbround18/valheim:latest
    stop_signal: SIGINT
    stop_grace_period: 2m
    ports:
      - "2456:2456/udp"
      - "2457:2457/udp"
      - "2458:2458/udp"
    environment:
      PORT: 2456
      NAME: "*****"
      WORLD: "*****"
      PASSWORD: "****"
      TZ: "Europe/Amsterdam"
      PUID: 1000
      GUID: 1000
      PUBLIC: 0
      AUTO_UPDATE: 0
      AUTO_UPDATE_SCHEDULE: "0 1 * * *"
      AUTO_BACKUP: 1
      AUTO_BACKUP_SCHEDULE: "*/15 * * * *"
      AUTO_BACKUP_REMOVE_OLD: 1
      AUTO_BACKUP_DAYS_TO_LIVE: 7
      AUTO_BACKUP_ON_UPDATE: 1
      AUTO_BACKUP_ON_SHUTDOWN: 1
#      TYPE: Vanilla
      TYPE: BepInEx
    volumes:
      - ./saves:/home/steam/.config/unity3d/IronGate/Valheim
      - ./server:/home/steam/valheim
      - ./backups:/home/steam/backups
mbround18 commented 1 year ago

Initial Thoughts

Maybe its the stop_signal: SIGINT ? ill give it a test.

With stop_signal: SIGINT

Found a house

image

Demolished it and added signature image

Without stop_signal: SIGINT

Found house still standing after restart

image

Now i close with my new "Work"

image

Post shutdown, the work sign wasn't there. I noticed an error in the log it wasnt finding the executable to shut it down,

Root Cause Analysis

Fix

Ill do some code changes after work to make it a little bit more clear in the shutdown and add more logs.

mbround18 commented 1 year ago

Fix Available in #735

Pre-restart

i created a sign

image

Post-restart

sign still present :) not a single piece missing

image

mbround18 commented 1 year ago

Fixed in https://github.com/mbround18/valheim-docker/releases/tag/v2.2.0

guyspr commented 1 year ago

I just tested it on my server and it has indeed been resolved. Thanks!