UseSystemd can detect an interactive shell as `running as systemd service`
See original GitHub issueDescribe the bug
I have my embedded platform and configure the IHostBuilder to .UseSystemd()
.
- Using the application as systemd service always works correctly.
- When I log into my system using SSH, I can run my application on the interactive prompt and it’s using ConsoleLifetime and console logging format.
- When I use the tty on the serial port to run the application, that’s detected as systemd environment and I get the systemd log format and termination behavior (no SIGINT handler)
The reason for the latter case is that my bash instance on the serial port inherits the INVOCATION_ID
environment variable through login
:
# env
LANG=C.UTF-8
OLDPWD=/
INVOCATION_ID=5561c5304f434119a45c4b6f260f1b00
EDITOR=vi
XDG_SESSION_ID=c1
HUSHLOGIN=FALSE
USER=root
PWD=/root
HOME=/root
JOURNAL_STREAM=8:13520
XDG_SESSION_TYPE=tty
MAIL=/var/spool/mail/root
SHELL=/bin/sh
TERM=putty
XDG_SESSION_CLASS=user
SHLVL=1
LOGNAME=root
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/0/bus
XDG_RUNTIME_DIR=/run/user/0
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
PS1=\u@\h:\w\$
_=/usr/bin/env
# pstree
systemd-+-…
|-login---sh---pstree
…
Issue Analytics
- State:
- Created 4 years ago
- Comments:20 (7 by maintainers)
Top Results From Across the Web
Difference between systemd and terminal starting program
Use systemctl show your-unit-unit.service to check the full configuration values affecting the service you attempting to start. Non-interactive ...
Read more >Interacting with a program running as part of a systemd ...
When the program is started, it provides a command line interface to allow interaction. However, as this program is run by systemd, I...
Read more >systemd-run
In this mode, systemd-run will start the service asynchronously in the background and return after the command has begun execution (unless --no-block or...
Read more >notification - How to use systemd notify
The systemd-notify tool is specifically meant to be used by a shell that runs as a systemd service using Type=notify .
Read more >Using systemd to execute an interactive (whiptail) script ...
It runs agetty as a daemon to provide the login sessions on ... Have a look in /usr/lib/systemd/system/getty@.service to see them in use....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
There’s a clear workaround here though, which is to have your own conditional logic prior to calling
UseSystemd
. Generally that means it wouldn’t meet the bar (especially given that it does have a breaking change angle).We don’t have a Systemd doc that I can find.