SQlite error when launching as systemd service
Subject of the Issue
Retro-Aim-Server (RAS) does not start when deployed as a systemd service
Deployment Environment
- Retro AIM Server Version: 0.16.1
- Installation Method: Pre-Built, Linux x86_64
- Other Relevant Details: Host is running Gentoo Linux x86_64
Steps to Reproduce
Added user "retroaim" and attached to group "retroaim"
Modified systemd .service file User and Group to match. Removed built in launch configuration and specified config to RAS settings file instead
Expected Behavior
Retro AIM Server runs
Actual Behavior
Sqlite seems to fail to launch with an "out of memory" error. The system has 32GB of RAM available
su-ing to the retroaim user and invoking the systemd exec function directly launches and operates as expected
Troubleshooting Data
May 10 22:26:37 CGHMN-SHAUN ras[38640]: Successfully loaded config file (/opt/retro-aim-server/settings.env)
May 10 22:26:37 CGHMN-SHAUN ras[38640]: error initializing common deps: unable to create feedbag store: failed to run migrations: cannot create database driver: unable to open database file: out of memory (14)
May 10 22:26:37 CGHMN-SHAUN systemd[1]: retro-aim-server.service: Main process exited, code=exited, status=1/FAILURE
Thanks for reporting!
I was able to reproduce this. The issue stems from a missing WorkingDirectory: the service is ran as user ras, however by default, all (root) systemd services are ran under /root (source).
So, the memory in question is not RAM, but disk memory; SQLite tries to write into /root without permissions and fails (and hence why using sudo everything works). The solution is to set WorkingDirectory to a path, where ras has r+w access.
I would suggest the usage of StateDirectory (documentation), since those directories will be created (and managed) by systemd.
Thanks for your analysis, very helpful!
fixed in v0.19.0