Skip to content
This repository has been archived by the owner on Jun 3, 2020. It is now read-only.

Log output (stdout) missing when running as systemd service #236

Closed
mdyring opened this issue Apr 20, 2019 · 9 comments
Closed

Log output (stdout) missing when running as systemd service #236

mdyring opened this issue Apr 20, 2019 · 9 comments

Comments

@mdyring
Copy link
Contributor

mdyring commented Apr 20, 2019

When running tmkms as a systemd service, nothing from stdout is logged for the service.

Not sure if I am doing anything unexpected, service file below:

[Unit]
Description=tmkms
Requires=network-online.target

[Service]
Environment="RUST_BACKTRACE=full"
ExecStart=/opt/tmkms/bin/tmkms start -c /opt/tmkms/config/tmkms.toml
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target

Would appreciate any pointers :-)

@tarcieri
Copy link
Contributor

tarcieri commented Apr 20, 2019

@mdyring thanks for opening an issue about this! It is definitely known, and I was just thinking about it earlier today, but we don't have an active tracking ticket about it, so thanks for opening one!

There is a somewhat awful workaround you can use in your systemd service unit file:

[Service]
TTYPath=/dev/ttyX

(where X is an available TTY, e.g. tty42)

This kludge will enable systemd logging with the existing logging code, which is (needlessly) dependent on a TTY.

I'm prepping another KMS release (probably tomorrow or monday) and will try to tackle this so the TTY kludge is not needed.

I am also definitely extremely interested in improving KMS logging in general, in particular moving to structured logging in some form, but that could probably use its own issue.

@mdyring
Copy link
Contributor Author

mdyring commented Apr 20, 2019

Cool, thanks. No rush on my part for structured logging, but would be great to get this specific issue fixed. :-)

@mdyring
Copy link
Contributor Author

mdyring commented Apr 20, 2019

After adding the TTYPath I get output like

Apr 20 23:18:27 kms2 tmkms[18624]: [138B blob data]
Apr 20 23:18:27 kms2 tmkms[18624]: [70B blob data]
Apr 20 23:18:29 kms2 tmkms[18624]: [123B blob data]

I am guessing this is due to the color sequences in the log output. If possible, it would be great to avoid these as well (or make optional via commandline flag)

@tarcieri
Copy link
Contributor

Opened #237 to discuss future logging improvements including structured logging

@tarcieri
Copy link
Contributor

@mdyring yeah, the colors should be gated on TTY detection (and/or an environment variable ala SYSTEMD_COLORS). The hooks are in place to both detect the TTY and allow overrides, it's just they're not being used by the logging subsystem yet.

@mdyring
Copy link
Contributor Author

mdyring commented Apr 24, 2019

As a note to self (or other in similar situation), journalctl -a will output the "blob" data.

@guyht
Copy link

guyht commented May 9, 2019

I have just run into this same issue, thanks for reporting.

@tarcieri
Copy link
Contributor

tarcieri commented May 9, 2019

I'm planning on doing another KMS release soon which will address this. Stay tuned!

tarcieri pushed a commit that referenced this issue Jun 18, 2019
This should be close to the final prerelease, and addresses a number of
issues:

- Better command-line option parsing UX
- Improved logging subsystem
- Eliminates many unnecessary dependencies
tarcieri pushed a commit that referenced this issue Jun 18, 2019
This should be close to the final prerelease, and addresses a number of
issues:

- Better command-line option parsing UX
- Improved logging subsystem
- Eliminates many unnecessary dependencies
tarcieri added a commit that referenced this issue Jun 18, 2019
Upgrade to abscissa v0.1.0-pre.2 (closes #236)
@tarcieri
Copy link
Contributor

Confirm this is fixed in tmkms v0.6.0-alpha2 (otherwise unannounced).

I'll try to get a v0.6.0-rc0 out you can try soon. Just be aware v0.6.0-alpha2 has not been fully tested on a live network.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants