Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Feature request, fork in background #229

Closed
skuti-is opened this issue Nov 7, 2017 · 7 comments
Closed

Feature request, fork in background #229

skuti-is opened this issue Nov 7, 2017 · 7 comments

Comments

@skuti-is
Copy link

skuti-is commented Nov 7, 2017

Add command line and config file option to fork in background and specify log file.

@dweggemans
Copy link

Any suggestions on how to do accomplish this with the current version?

@DimitriPapadopoulos
Copy link
Collaborator

DimitriPapadopoulos commented Jun 9, 2018

You may start openfortivpn as a systemd service:

  • StandardOutput= should redirect the output of openfortivpn to a file.
  • With Type=simple, I think the PID of openfortivpn is known to systemd.
  • Restart= can be used instead of --persistent.
  • Is forking really required?

As was the case with --persistent, I would rather see daemon-like options implemented in systemd. Perhaps we could create a wiki to explain how to start openfortivpn as a service. Alternatively, if really needed inside openfortivpn, the requested functionality could perhaps be implemented in a daemonize() function that could include the --persistent functionality.

@skuti-is @dweggemans Can you expand on why it would be better to implement daemon-like functionality in openfortivpn rather than use systemd? I am not against the suggestion by the way, just trying to get the big picture.

See also #228.

@jandersonbt
Copy link

I second the systemd options. Using existing technologies to accomplish tasks is always best. I would also like to see the ability to use Type=notify in the service file. Currently, I am working on a project where other services need to start after openfortivpn has the tunnel up and running. However, when using Type=simple in my systemd service file the service shows as complete before the tunnel is up and running. I can see this behavior when using tail -f to view the syslog file while restarting the openfortivpn service. I did attempt to use the Type=notify option, however openfortivpn doesn't notify systemd when the tunnel is up and running, and this leaves the systemctl command hanging. I've been reviewing systemd documentation, but I have yet to find a way around the notify option to accomplish what I need. Currently, I'm using a sleep command to pause while the vpn connects. This works as long as the vpn connects quickly.

@DimitriPapadopoulos
Copy link
Collaborator

@jandersonbt Any clue/link how to implement the systemd notification? Additional headers needed and libraries to link with?

@DimitriPapadopoulos
Copy link
Collaborator

Any clue about systemd-like functionality on FreeBSD and macOS?

@DimitriPapadopoulos
Copy link
Collaborator

@jandersonbt Would it be possible to parse openfortivpn output (in an encapsulating script?) to notify systemd, perhaps using systemd-notify?

@jandersonbt
Copy link

@DimitriPapadopoulos The link below details the sd_notify function that can be used to send ready and error notifications to systemd. It is included in the C library libsystemd-dev, at least that is the package name in Ubuntu 18.04.
https://www.freedesktop.org/software/systemd/man/sd_notify.html

From what I read, the suggested systemd-notify is not as reliable as using the sd_notify library. However, in the near term I did find a python module called sdnotify and wrapped the openfortivpn command in a python script that allow's me to notify systemd when I see 'Tunnel is up' in the output. While this solution is working well so far, it would be nice to have systemd support build into openfortivpn.

Unfortunately, my knowledge with FreeBSD and MacOS is extremely limited. Sorry...

fsateler added a commit to fsateler/openfortivpn that referenced this issue Sep 11, 2018
Allows usage of Type=notify systemd service types.

Fixes: adrienverge#229
fsateler added a commit to fsateler/openfortivpn that referenced this issue Sep 11, 2018
Allows usage of Type=notify systemd service types.

Fixes: adrienverge#229
DimitriPapadopoulos pushed a commit that referenced this issue Sep 12, 2018
Allows usage of Type=notify systemd service types.

Fixes: #229
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants