This weekend I was working on setting up my XBMC server. To do this is need to run serveral programs, but I came to the conclusion that init is changed to systemd.
Not a problem you should say, however with init you could create daemon processes, which I could not find with systemd.
Solution was to build my own Daemonizer script per program where needed (since the programs I wanted to don’t have PID).
Problem is that I don’t see how to use it. Of course I did fill in the daemon name and run as user.
After that I can compile with:
gcc -Wall daemon_script.c -o deamon
Which can be executed, but there doesn’t happen a thing, so probably I do something wrong.
Please help me out, read complete artikel on the website but doesn’t give me a clue?
Update:
Oke, working a little however a PID in /var/run is still missing and I get an error on:
“/var/lock/subsys/”
Because that folder does not exist on OpenSuSe 12.1. Hoe should this be adjusted to make it working.
Furthermore, how do I get a PID.
On 2012-06-03 13:56, TUDStudent wrote:
>
> All,
>
> This weekend I was working on setting up my XBMC server. To do this is
> need to run serveral programs, but I came to the conclusion that init is
> changed to systemd.
> Not a problem you should say, however with init you could create daemon
> processes, which I could not find with systemd.
I’m sure you can launch with systemd any program as was done with systemv -
but don’t ask me how.
Being a daemon or not is a secondary thing.
–
Cheers / Saludos,
Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)
If your daemon depends on some other processes you should add it to After section. Maybe you also want to replace daemon_user with the your spcific daemon user. Then copy this file to /etc/systemd/system/daemon.service, reload configuration with
systemctl --system daemon-reload
and start it with systemctl start daemon.service that’s it. To enable it on startup just type systemctl enable daemon.service. It’s really quite simple, isn’t it Hope this helps
I am afraid that @Monex, while using CODE tags, did not realy copied/pasted directly from the terminal into the post. Thus the Line feeds are gone. Can you please repost or this this realy as it should be?
If your daemon depends on some other processes you should add it to After section. Maybe you also want to replace daemon_user with the your spcific daemon user.
Then copy this file to /etc/systemd/system/daemon.service, reload configuration with
systemctl --system daemon-reload
and start it with systemctl start daemon.service that’s it.
To enable it on startup just type systemctl enable daemon.service. It’s really quite simple, isn’t it
It realy is simple and it is shown here earlier. But I allways forget where to find it.
Will now make a copy of your example in a file here. Hope I will remember I have that file somewhere when tiimes comes
Jun 3 22:00:18 linux-7ffb systemd[1608]: Failed at step EXEC spawning /usr/local/bin/daemon: No such file or directory
Jun 3 22:00:18 linux-7ffb systemd[1]: daemon.service: main process exited, code=exited, status=203
Jun 3 22:00:18 linux-7ffb systemd[1]: Unit daemon.service entered failed state.
Getting the above error in my messages. Do I mis an RPM to get this working, or is it located somewhere else.
(I really do not have this folder/file -> Opensuse 12.1)
Don’t you understand that you have to fill in your parameters? E.g. for the example of /usr/local/bin/deamon you should of course replace it wiith the path to your own script, wherever it may be. And of course all the others. I would not believe you also use a name as “My cool deamon”???
To be honest, I cannot match the various statements you’re posting. But it does raise a question: have you been trying to do this on WIndows?
To be a service or a daemon, is not determined by whether there’s a pid file in /var/run. Take a look at the existing .service files, at some of the scripts in /etc/init.d
Consider a “while true do " construction, run it in the background by adding " &” to the script/command.