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
=== modified file 'epoptes-client/epoptes-client'
--- epoptes-client/epoptes-client 2015-10-06 19:14:31 +0000
+++ epoptes-client/epoptes-client 2015-10-23 18:07:51 +0000
@@ -230,15 +230,52 @@
230 cert_param="verify=0"230 cert_param="verify=0"
231fi231fi
232232
233# Connect to the server, or keep retrying until the server gets online
234# (for standalone workstations booted before the server).
235if [ -s /etc/epoptes/server.crt ] || [ "$cert_param" = "verify=0" ]; then233if [ -s /etc/epoptes/server.crt ] || [ "$cert_param" = "verify=0" ]; then
236 exec socat openssl-connect:$SERVER:$PORT,$cert_param,interval=60,forever EXEC:"$cmdline"234 socat_prefix="openssl-connect"
235 socat_cert=",$cert_param"
236 socat_suffix=""
237elif [ -f /etc/epoptes/server.crt ]; then237elif [ -f /etc/epoptes/server.crt ]; then
238 exec socat tcp:$SERVER:$PORT,interval=60,forever EXEC:"$cmdline",nofork238 socat_prefix="tcp"
239 socat_cert=""
240 socat_suffix=",nofork"
239else241else
240 die "242 die "
241The epoptes certificate file, /etc/epoptes/server.crt, doesn't exist.243The epoptes certificate file, /etc/epoptes/server.crt, doesn't exist.
242You can fetch the server certificate by running:244You can fetch the server certificate by running:
243$0 -c"245$0 -c"
246 exit 1
247fi
248
249# Connect to the server, or keep retrying until the server gets online
250# (for standalone workstations booted before the server).
251# Uses SIGTERM-propagation scheme as proposed in
252# http://veithen.github.io/2014/11/16/sigterm-propagation.html
253if [ "$TYPE" = "standalone" ]; then
254 trap 'kill -TERM $socat_pid; KEEP_ALIVE=false' TERM INT
255 KEEP_ALIVE=true
256
257 while $KEEP_ALIVE; do
258 socat ${socat_prefix}:${SERVER}:${PORT}${socat_cert},interval=60,forever EXEC:"$cmdline"${socat_suffix} &
259 socat_pid=$!
260 wait $socat_pid
261 trap - TERM INT
262 wait $socat_pid
263 socat_ret=$?
264
265 # Just in case we don't receive a SIGTERM
266 # from session manager on logout,
267 # ask systemd-logind (if available)
268 # if we can quit safely.
269 [ "$(loginctl show-session -p State $XDG_SESSION_ID | cut -d= -f2)" = "closing" ] && KEEP_ALIVE=false
270
271 if [ $socat_ret -eq 0 ]; then
272 socat_message="Connection lost"
273 else
274 socat_message="WARNING: socat exited with unexpected code $socat_ret"
275 fi
276
277 $KEEP_ALIVE && log_begin_msg "${socat_message}. Epoptes-client reconnecting to $SERVER:$PORT..."
278 done
279else
280 exec socat ${socat_prefix}:${SERVER}:${PORT}${socat_cert},interval=60,forever EXEC:"$cmdline"${socat_suffix}
244fi281fi

Subscribers

People subscribed via source and target branches