Merge lp:~oiteam/epoptes/auto-reconnect into lp:~epoptes/epoptes/exported-translations

Proposed by Laércio de Sousa
Status: Rejected
Rejected by: Alkis Georgopoulos
Proposed branch: lp:~oiteam/epoptes/auto-reconnect
Merge into: lp:~epoptes/epoptes/exported-translations
Diff against target: 60 lines (+41/-4)
1 file modified
epoptes-client/epoptes-client (+41/-4)
To merge this branch: bzr merge lp:~oiteam/epoptes/auto-reconnect
Reviewer Review Type Date Requested Status
Alkis Georgopoulos Disapprove
Review via email: mp+273468@code.launchpad.net

Description of the change

Re-proposing this merge after some rework following Alkis advices (via IRC).

To post a comment you must log in.
lp:~oiteam/epoptes/auto-reconnect updated
391. By Laércio de Sousa

Rename variables to avoid potential conflicts with ones set by socat itself.

392. By Laércio de Sousa

Reintroduce asking to systemd-logind if current session is closing, as epoptes-client may not receive a SIGTERM from session manager on logout.

Revision history for this message
Alkis Georgopoulos (alkisg) wrote :

Hi Laércio,

thanks for the patch, but it was rather harder than a loop, so I'll close this branch.

Reconnections were implemented in:
http://bazaar.launchpad.net/~epoptes/epoptes/trunk/revision/458

Keeping the connections were implemented in:
http://bazaar.launchpad.net/~epoptes/epoptes/trunk/revision/457

And there will be another commit for reconnecting the GUI to the epoptes service.

Please comment on if the above commits work for you!

review: Disapprove

Unmerged revisions

392. By Laércio de Sousa

Reintroduce asking to systemd-logind if current session is closing, as epoptes-client may not receive a SIGTERM from session manager on logout.

391. By Laércio de Sousa

Rename variables to avoid potential conflicts with ones set by socat itself.

390. By Laércio de Sousa

Merge with trunk

389. By Laércio de Sousa

Update auto-reconnect heuristic to terminate gracefully when logind session terminates, but also deal with non-systemd contexts.

388. By Laércio de Sousa

Revert revision 387. We'll follow another systemd-independent approach.

387. By Laércio de Sousa

Stop trying to reconnect if systemd-logind session is closing

386. By Laércio de Sousa

Keep reconnecting even if socat ends unexpectedly (exit code != 0).

385. By Laércio de Sousa

Add a "sleep 1" inside while loops, just for precaution.

384. By Laércio de Sousa

Restore original behaviour (no auto-reconnect) for thin/fat clients only.

383. By Laércio de Sousa

Fix coding style consistency

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'epoptes-client/epoptes-client'
2--- epoptes-client/epoptes-client 2015-10-06 19:14:31 +0000
3+++ epoptes-client/epoptes-client 2015-10-23 18:07:51 +0000
4@@ -230,15 +230,52 @@
5 cert_param="verify=0"
6 fi
7
8-# Connect to the server, or keep retrying until the server gets online
9-# (for standalone workstations booted before the server).
10 if [ -s /etc/epoptes/server.crt ] || [ "$cert_param" = "verify=0" ]; then
11- exec socat openssl-connect:$SERVER:$PORT,$cert_param,interval=60,forever EXEC:"$cmdline"
12+ socat_prefix="openssl-connect"
13+ socat_cert=",$cert_param"
14+ socat_suffix=""
15 elif [ -f /etc/epoptes/server.crt ]; then
16- exec socat tcp:$SERVER:$PORT,interval=60,forever EXEC:"$cmdline",nofork
17+ socat_prefix="tcp"
18+ socat_cert=""
19+ socat_suffix=",nofork"
20 else
21 die "
22 The epoptes certificate file, /etc/epoptes/server.crt, doesn't exist.
23 You can fetch the server certificate by running:
24 $0 -c"
25+ exit 1
26+fi
27+
28+# Connect to the server, or keep retrying until the server gets online
29+# (for standalone workstations booted before the server).
30+# Uses SIGTERM-propagation scheme as proposed in
31+# http://veithen.github.io/2014/11/16/sigterm-propagation.html
32+if [ "$TYPE" = "standalone" ]; then
33+ trap 'kill -TERM $socat_pid; KEEP_ALIVE=false' TERM INT
34+ KEEP_ALIVE=true
35+
36+ while $KEEP_ALIVE; do
37+ socat ${socat_prefix}:${SERVER}:${PORT}${socat_cert},interval=60,forever EXEC:"$cmdline"${socat_suffix} &
38+ socat_pid=$!
39+ wait $socat_pid
40+ trap - TERM INT
41+ wait $socat_pid
42+ socat_ret=$?
43+
44+ # Just in case we don't receive a SIGTERM
45+ # from session manager on logout,
46+ # ask systemd-logind (if available)
47+ # if we can quit safely.
48+ [ "$(loginctl show-session -p State $XDG_SESSION_ID | cut -d= -f2)" = "closing" ] && KEEP_ALIVE=false
49+
50+ if [ $socat_ret -eq 0 ]; then
51+ socat_message="Connection lost"
52+ else
53+ socat_message="WARNING: socat exited with unexpected code $socat_ret"
54+ fi
55+
56+ $KEEP_ALIVE && log_begin_msg "${socat_message}. Epoptes-client reconnecting to $SERVER:$PORT..."
57+ done
58+else
59+ exec socat ${socat_prefix}:${SERVER}:${PORT}${socat_cert},interval=60,forever EXEC:"$cmdline"${socat_suffix}
60 fi

Subscribers

People subscribed via source and target branches