Skip to content

Fix user retention - #62

Merged
thiagoralves merged 2 commits into
mainfrom
development
Jan 3, 2026
Merged

Fix user retention#62
thiagoralves merged 2 commits into
mainfrom
development

Conversation

@thiagoralves

Copy link
Copy Markdown
Contributor

This pull request improves the handling of runtime and persistent data directories for both containerized and native Linux installations. The changes ensure that data such as the .env file and database are stored in the correct location depending on the environment, increasing robustness and making sure persistent data survives system reboots outside containers. A new utility function also detects whether the application is running inside a container.

Persistent data management improvements:

  • Added the get_persistent_data_dir() function in webserver/config.py to select the appropriate directory for persistent data based on whether the app is running in a container or on native Linux/MSYS2. Persistent data is now stored in /var/lib/openplc-runtime on native Linux, and /var/run/runtime in containers and MSYS2/Windows.
  • Updated the definitions of ENV_PATH and DB_PATH in webserver/config.py to use the new persistent data directory, ensuring these files are stored in a location that survives reboots on native Linux.

Container detection and directory setup:

  • Added the is_running_in_container() function in webserver/config.py to robustly detect if the application is running inside a container using multiple heuristics.
  • Modified install.sh to create /var/lib/openplc-runtime with appropriate permissions for native Linux installs with systemd support, ensuring the persistent data directory exists.

Documentation and comments:

  • Improved comments in webserver/config.py to clarify the logic for selecting runtime and persistent data directories depending on platform and environment.

devin-ai-integration Bot and others added 2 commits January 2, 2026 23:38
- Add is_running_in_container() function to detect Docker/Podman environments
- Add get_persistent_data_dir() function to determine where to store persistent data
- On native Linux: use /var/lib/openplc-runtime for .env and database files
- On containers: continue using /var/run/runtime (mounted as persistent volume)
- Update installer to create /var/lib/openplc-runtime when systemd is available

This fixes the issue where user credentials were lost after reboot because
/var/run/runtime is a tmpfs that gets cleared on reboot. The .env file
regeneration would then delete the database since new secrets invalidate
old password hashes.

Container detection checks:
- /.dockerenv file existence
- container/DOCKER_CONTAINER environment variables
- /proc/1/cgroup for docker/kubepods/lxc/containerd patterns
- /proc/1/environ for container= variable

Co-Authored-By: Thiago Alves <thiagoralves@gmail.com>
…persistence

Fix user data persistence across reboots for native Linux installs
@thiagoralves
thiagoralves merged commit 810d6a8 into main Jan 3, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant