Make Database Engine Default to /var/lib Directory
This is RFE to make the applications default database location be one of the following or similar:
```
/var/lib/platypush/main.db
/var/lib/platypush/database.db
/var/lib/platypush/db/main.db
```
Context:
I've been using platypush for a few days to test it out since it seems promising, I like your direction for the project and your Medium articles are well written. For reference the below is from testing when I was writing an Ansible role to automatically setup the service so I can redeploy on different machines if something happens.
When installing the daemon I was trying to keep it contained since it's not a system package. I was installing everything `/opt/platypush` where I had:
`/opt/platypush/venv` was the Python virtual environment
`/opt/platypush/config` was the `config.yaml`
`/opt/platypush/log` were the log files.
I then created a system user with no home directory and a shell `/sbin/nologin` as I don't want the daemon user to have any more permissions then it should. You shouldn't be able to login to the user and it doesn't need a home directory as it only really needs to run the dameon. This caused issues because of [config module](https://github.com/BlackLight/platypush/blob/master/platypush/config/__init__.py#L92) always defaults the engine to `~/.local/share/platypush/main.db`. I also noticed the [working directory](https://github.com/BlackLight/platypush/blob/master/platypush/config/__init__.py#L48) is the same.
I know you can [override it](https://github.com/BlackLight/platypush/wiki/run-platypush-in-a-virtual-environment) in the `config.yaml` but as a system user it would be best to not default to a user's home directory for data as it's not guaranteed to exists for system users or system installs. From [`man hier.7`](https://man7.org/linux/man-pages/man7/hier.7.html) this would probably be best suited for `/var/lib/<package>` since it contains state data for packages and subsystems. Other packages store daemon databases here.
Currently the default `config.yaml` & log files are in respective system directories, `/etc/platypush` & `/var/log/platypush` and only the DB isn't. Because of this you'll get errors if you make a non-home system user who doesn't have a home directory and `/home/<user>/.local/share/platypush/` doesn't exists.
A command line flag should probably also exists for the DB path and logs (which can only be override via `config.yaml`) but I'll submit that as a different ticket.
关闭于 2023-07-24 2 条评论