Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weirdness with config handling #291

Open
jacklul opened this issue Apr 22, 2024 · 0 comments
Open

Weirdness with config handling #291

jacklul opened this issue Apr 22, 2024 · 0 comments

Comments

@jacklul
Copy link

jacklul commented Apr 22, 2024

I'm noticing there are some weirdness with config handling.
The app also sets 755 permissions on the config.yml which doesn't make any sense.

Linux raspberry-pi 6.1.21+ #1642 Mon Apr 3 17:19:14 BST 2023 armv6l GNU/Linux
Legacy Raspberry Pi OS based on Debian 11

Running with /usr/local/bin/statping -c /etc/statping/config.yml -s 127.0.0.1 -p 8850 and this config:

connection: sqlite3
language: en
allow_reports: false
location: /etc/statping
sqlfile: /etc/statping/database.db
disable_http: false
demo_mode: false
disable_logs: true
use_assets: false
sample_data: false
use_cdn: false
disable_colors: false

makes the config file get overwritten on launch with this:

connection: sqlite3
language: en
location: /etc/statping
sqlfile: /etc/statping/statping.db
disable_http: false
demo_mode: false
disable_logs: false
use_assets: false
sample_data: false
use_cdn: false
disable_colors: false

Startup log:

Apr 22 16:59:00 raspberry-pi statping[17607]: INFO[0000] Starting Statping v0.91.0                     type=cmd
Apr 22 16:59:00 raspberry-pi statping[17607]: INFO[0000] Attempting to read config file at: /etc/statping/config.yaml  type=configs
Apr 22 16:59:00 raspberry-pi statping[17607]: INFO[0000] SQL database file at: /etc/statping/statping.db  type=configs
Apr 22 16:59:00 raspberry-pi statping[17607]: INFO[0000] Database sqlite3 connection was successful.   type=configs
Apr 22 16:59:00 raspberry-pi statping[17607]: INFO[0000] Migrating Database Tables...                  type=configs
Apr 22 16:59:01 raspberry-pi statping[17607]: INFO[0000] Migrating App to version: v0.91.0 (66a1adaa66acfa9615d5b8661e3c0320109731c3)  type=configs
Apr 22 16:59:01 raspberry-pi statping[17607]: INFO[0001] Statping Database Tables Migrated             type=configs
Apr 22 16:59:01 raspberry-pi statping[17607]: INFO[0001] Database Indexes Created                      type=configs
Apr 22 16:59:02 raspberry-pi statping[17607]: INFO[0002] Starting monitoring process for 0 Services    type=service
Apr 22 16:59:02 raspberry-pi statping[17607]: INFO[0002] Statping HTTP Server running on http://127.0.0.1:8850/  type=handlers

It migrates database and app every launch so I assume that's where the config overwrite bug comes from.

service file:

[Unit]
Description=Statping-ng
Documentation=https://github.com/statping-ng/statping-ng
After=network-online.target
Wants=network-online.target

[Service]
EnvironmentFile=/etc/statping/config
ExecStart=/usr/local/bin/statping --ip 127.0.0.1 --port 8850
#ExecStart=/usr/local/bin/statping --config /etc/statping/config.yaml --ip 127.0.0.1 --port 8850
Restart=on-failure
User=statping
ProtectSystem=full
ReadWriteDirectories=/etc/statping
WorkingDirectory=/etc/statping

[Install]
WantedBy=multi-user.target

Same issue without protection directives set.

So, I changed my startup line to /usr/local/bin/statping -c /etc/statping/config.yaml -s 127.0.0.1 -p 8850 and guess what - /etc/statping/config.yaml is untouched but still some settings does not take effect, database still reverts to /etc/statping/statping.db and allow_reports sets itself to true.

In the end I moved my config to using environment file (loaded through EnvironmentFile= in systemd service), unfortunately DB_DSN doesn't seem to work to define custom sqlite database file path (tried various variation I know and none of them work), SQLFILE doesn't work either.

statping env gives a lot of variables but most of them do not work when set (IP and PORT being one of them which is weird).

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

No branches or pull requests

1 participant