On 29/11/16 16:27, Christian Hesse wrote:
> From: Christian Hesse <m...@eworm.de>
> 
> Notify systemd service manager when our initialization sequence
> completed. This helps ordering services as dependencies can rely on vpn
> being available.

Funny detail is that I have a somewhat similar patch in a local git
tree, awaiting proper testing ... I postponed it as this is not
something we will pull into v2.4.  We're going to release 2.4_rc1 this
week, and that is too late for more intrusive changes (even though the
changeset itself is small, the code changes makes OpenVPN behave
somewhat different when managed by systemd).

Just a question, as it is good to see more people looking into these
code paths ... I was considering to extend my approach to update STATUS=
a bit more frequently.  On the client side, I thought it would be good
if the status line had "Resolving %s", "Connecting to %s", "Successful
connection to %s" or "Failed to connect to %s".  On the server side I
was pondering on a "Successfully started, %i clients connected".  What
do you think about that?  Does the sd_notify() API support more frequent
updates?

Also when using Type=notify ... does systemd expect the OpenVPN process
to fork into the background or run in the foreground as now?


-- 
kind regards,

David Sommerseth
OpenVPN Technologies, Inc








> ---
>  distro/systemd/openvpn-client@.service | 1 +
>  distro/systemd/openvpn-server@.service | 1 +
>  src/openvpn/init.c                     | 6 ++++++
>  src/openvpn/init.h                     | 4 ++++
>  4 files changed, 12 insertions(+)
> 
> diff --git a/distro/systemd/openvpn-client@.service 
> b/distro/systemd/openvpn-client@.service
> index 18b84dd..f64a239 100644
> --- a/distro/systemd/openvpn-client@.service
> +++ b/distro/systemd/openvpn-client@.service
> @@ -7,6 +7,7 @@ 
> Documentation=https://community.openvpn.net/openvpn/wiki/Openvpn24ManPage
>  Documentation=https://community.openvpn.net/openvpn/wiki/HOWTO
>  
>  [Service]
> +Type=notify
>  PrivateTmp=true
>  RuntimeDirectory=openvpn-client
>  RuntimeDirectoryMode=0710
> diff --git a/distro/systemd/openvpn-server@.service 
> b/distro/systemd/openvpn-server@.service
> index a2b7b52..890e6a9 100644
> --- a/distro/systemd/openvpn-server@.service
> +++ b/distro/systemd/openvpn-server@.service
> @@ -7,6 +7,7 @@ 
> Documentation=https://community.openvpn.net/openvpn/wiki/Openvpn24ManPage
>  Documentation=https://community.openvpn.net/openvpn/wiki/HOWTO
>  
>  [Service]
> +Type=notify
>  PrivateTmp=true
>  RuntimeDirectory=openvpn-server
>  RuntimeDirectoryMode=0710
> diff --git a/src/openvpn/init.c b/src/openvpn/init.c
> index 2ccbab2..551e579 100644
> --- a/src/openvpn/init.c
> +++ b/src/openvpn/init.c
> @@ -1251,10 +1251,16 @@ initialization_sequence_completed (struct context *c, 
> const unsigned int flags)
>        show_adapters (M_INFO|M_NOPREFIX);
>        msg (M_INFO, "%s With Errors ( see 
> http://openvpn.net/faq.html#dhcpclientserv )", message);
>  #else
> +#ifdef ENABLE_SYSTEMD
> +      sd_notifyf(0, "STATUS=Failed to start up: %s With Errors\nERRNO=1", 
> message);
> +#endif /* HAVE_SYSTEMD_SD_DAEMON_H */
>        msg (M_INFO, "%s With Errors", message);
>  #endif
>      }
>    else
> +#ifdef ENABLE_SYSTEMD
> +    sd_notifyf(0, "READY=1\nSTATUS=%s\nMAINPID=%lu", message, (unsigned 
> long) getpid());
> +#endif
>      msg (M_INFO, "%s", message);
>  
>    /* Flag that we initialized */
> diff --git a/src/openvpn/init.h b/src/openvpn/init.h
> index 524bc64..0518b06 100644
> --- a/src/openvpn/init.h
> +++ b/src/openvpn/init.h
> @@ -27,6 +27,10 @@
>  
>  #include "openvpn.h"
>  
> +#ifdef ENABLE_SYSTEMD
> +#include <systemd/sd-daemon.h>
> +#endif
> +
>  /*
>   * Baseline maximum number of events
>   * to wait for.
> 


Attachment: signature.asc
Description: OpenPGP digital signature

------------------------------------------------------------------------------
_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to