I have a program written in Go that programmatically creates and manages screens. Here's an example:
_, err := exec.Command("screen", "-S", "screen-"+strings.ToLower(name), "-X", "stuff", command+"
").Output()
This works fine. When I Control+C the program, the screens created stay open (what I want!). However, I've converted it into a background service on Ubuntu. When I run systemctl stop <service>
, it kills those screens without a warning. Attaching to a screen doesn't stop this either (instantly goes to [screen terminated]
). It doesn't kill screens created externally, however.
Here is my .service
:
[Unit]
Description=>servicename> background service
After=network-online.target
[Service]
ExecStart=/usr/lib/<servicename>/service
[Install]
WantedBy=multi-user.target
My rules
:
%:
dh $@ --with systemd --parallel
override_dh_auto_install:
dh_auto_install
dh_systemd_enable || true
dh_systemd_start || true
My control
:
Package: <name>
Version: 0.2
Architecture: amd64
Priority: optional
Maintainer: <me>
Description: <description>
Depends: screen, iptables
Build-Depends: dh-systemd (>=1.5)
I can't imagine what would cause these screens to kill. I'm pretty sure they're not being attached in the program because it runs fine as an executable. System logs don't mention anything outside of "service stopped' and 'service started'. I've tried making screens under root, different users, running an empty screen vs running a program, etc. Nothing notable.
Any ideas?
question from:
https://stackoverflow.com/questions/65648532/systemctl-killing-detached-screens 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…