Closed mh-cbon closed 1 year ago
Hi again,
I have done testing a service using systemd, and it definitely hangs.
While waiting for the stop event to finish,
$ systemctl --user status bootstrap.service
● bootstrap.service - Bootstrap website
Loaded: loaded (/home/mh-cbon/.config/systemd/user/bootstrap.service; enabled; vendor preset: disabled)
Active: deactivating (stop-sigterm) since Sun 2022-08-14 22:13:34 CEST; 25s ago
Main PID: 81085 (bootstrap)
Tasks: 10 (limit: 18894)
Memory: 22.9M
CPU: 2.855s
CGroup: /user.slice/user-1000.slice/user@1000.service/app.slice/bootstrap.service
└─ 81085 /home/mh-cbon/mon-blog/bootstrap/bootstrap
août 14 22:13:16 Host-001 bootstrap[81085]: Read line: 650 HS_DESC UPLOADED zvsyv4co2jkargvjr2hyhaxjdlcivcramlnxy34xp2geap7ckhnaddyd UNKNOWN $3417F1F24A7CA4033DB514610321A1A9F4>
août 14 22:13:16 Host-001 bootstrap[81085]: Read line: 650 HS_DESC UPLOADED zvsyv4co2jkargvjr2hyhaxjdlcivcramlnxy34xp2geap7ckhnaddyd UNKNOWN $0AE25E26120B6866F548A0FCCF087A1F76>
août 14 22:13:16 Host-001 bootstrap[81085]: Write line: SETEVENTS
août 14 22:13:16 Host-001 bootstrap[81085]: Read line: 250 OK
août 14 22:13:16 Host-001 bootstrap[81085]: INFO[0010] bootstrap: Onion ready at http://zvsyv4co2jkargvjr2hyhaxjdlcivcramlnxy34xp2geap7ckhnaddyd.onion
août 14 22:13:18 Host-001 bootstrap[81085]: INFO[0013] upnp: found 1 clients
août 14 22:13:18 Host-001 bootstrap[81085]: INFO[0013] bootstrap: Website ready at http://muarf/
août 14 22:13:18 Host-001 bootstrap[81085]: INFO[0013] bootstrap: static website running at http://127.0.0.1:33853/
août 14 22:13:34 Host-001 bootstrap[81085]: Aug 14 22:13:34.000 [notice] Catching signal TERM, exiting cleanly.
août 14 22:13:34 Host-001 systemd[1499]: Stopping bootstrap.service - Bootstrap hugo website...
Later some timeout occurred, thus, i will configure it low.
$ systemctl --user status bootstrap.service
× bootstrap.service - Bootstrap hugo website
Loaded: loaded (/home/mh-cbon/.config/systemd/user/bootstrap.service; enabled; vendor preset: disabled)
Active: failed (Result: timeout) since Sun 2022-08-14 22:15:04 CEST; 15s ago
Process: 81085 ExecStart=/home/mh-cbon/mon-blog/bootstrap/bootstrap (code=killed, signal=KILL)
Main PID: 81085 (code=killed, signal=KILL)
CPU: 2.875s
août 14 22:15:04 Host-001 systemd[1499]: bootstrap.service: State 'stop-sigterm' timed out. Killing.
août 14 22:15:04 Host-001 systemd[1499]: bootstrap.service: Killing process 81085 (bootstrap) with signal SIGKILL.
août 14 22:15:04 Host-001 systemd[1499]: bootstrap.service: Killing process 81087 (bootstrap) with signal SIGKILL.
août 14 22:15:04 Host-001 systemd[1499]: bootstrap.service: Killing process 81090 (n/a) with signal SIGKILL.
août 14 22:15:04 Host-001 systemd[1499]: bootstrap.service: Killing process 81095 (n/a) with signal SIGKILL.
août 14 22:15:04 Host-001 systemd[1499]: bootstrap.service: Killing process 81160 (n/a) with signal SIGKILL.
août 14 22:15:04 Host-001 systemd[1499]: bootstrap.service: Main process exited, code=killed, status=9/KILL
août 14 22:15:04 Host-001 systemd[1499]: bootstrap.service: Failed with result 'timeout'.
août 14 22:15:04 Host-001 systemd[1499]: Stopped bootstrap.service - Bootstrap hugo website.
août 14 22:15:04 Host-001 systemd[1499]: bootstrap.service: Consumed 2.875s CPU time.
Using the systemd directive under the System block TimeoutStopSec=5
it works oki-sh,
the stop command does not hang.
Hi,
A small issue here regarding the signal capture and exit sequence.
Upon receiving the interrupt signal, i can see the Tor process handles it (there is a log line, and the onion respond with 0xF2). But the Go program, it is not notified, an additional signal is required to get it done.
I also tried to wait, in the hope some timeout would occur, but no luck.
I am a bit concerned by this behavior in the perspective of a service setup (but maybe I should not).
Some logs and data, stripped for clarity.
System
The Program output
In that log i waited like 5 minutes before giving up.
My code is super boring, I have a small func, which mostly copy paste your examples, with a small wrapper, and some calling code relying on the stdlib to capture the signal and a context to wait on.
The caller code is like
originally posted at https://github.com/cretz/bine/issues/68