You are not logged in.
I'm trying to understand something about systemd and daemons.
Here's the setup: I can start openvpn by the command line as a daemon with the "daemon" parameter in the openvpn config file. It all works fine. No questions so far...
To find my daemon, I use the following command and can see it:
ps -ef | grep openvpn
And to stop openvpn, the only way that I know how to do this (when it's running as a daemon) to issue this command:
sudo pkill -SIGTERM openvpn
Again, it works fine and openvpn is now stopped.
Here my question: Is there a way using systemd to stop and even restart openvpn in the way that I'm running it - as a daemon? Or does systemctl stop/restart only work when the daemon is running as a systemd service?
Again, everything is working fine - I'm just trying to understand systemd and daemons a bit better.
Cheers!
Last edited by julesm (2015-08-24 17:33:27)
Offline
Read the openvpn service file...
Offline
I don't know whether systemd is able to stop or restart process not started with systemctl, but I think the recommended way is to start, stop, restart, etc with systemctl. (manually for testing)
You can start a daemon using systemctl with one of the commands (depending on what you want, client or server):
# systemctl start openvpn@server.service
# systemctl start openvpn@client.service
Offline
information that can be found in the OpenVPN wiki page.
Offline
Many thanks for all of that. But what I'm asking (I believe) is slightly different.
The wiki page mainly talks about starting openvpn as a service. That's not what I'm doing. I'm starting it as a daemon manually and I want to know if I can then use systemd to stop/restart it. I know that if I start openvpn as a service then I can use systemd.
But can you stop/restart using systemd a daemon that you've started manually? That's my question.
I've probably muddied the waters by using openvpn as an example. My question has little if anything to do with openvpn...
Last edited by julesm (2015-08-24 11:25:13)
Offline
No you can't. When a process is daemonized, it just means it forked off so that it doesn't get closed when the parent process gets closed. You can do this with any program. systemd does not stop those for you. To stop a manually started daemon, find its PID and use kill. Well behaved daemonized process make a pid file with their PID in it. (Pid files are what rc scripts use to stop daemons.)
aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies
Offline
can you stop/restart using systemd a daemon that you've started manually?
Already answered by fsckd, but I'm curious why you think you need this? Seems obvious to me that if you want to use systemd, you should use systemd. If you want to do things manually, do that instead. What would you achieve by this mix-n-match approach, even if it was possible?
Offline
Excellent - fsckd - that was just the explanation and understanding that I was after! Thanks again for that!
tomk, the more I get into Arch, the more stuff I try and I think about...sometimes it's a bit of a rabbit hole - doing one thing makes me wonder about another and then I find myself wondering how that works and whether I could do something else altogether - even if I'm not going to...but I suppose that's what makes Arch so much fun - it gets you thinking and trying out things that you wouldn't otherwise dare do!
Thanks again for the info! Now I understand it much, much better!
Jules
Offline