Talk:Run as a daemon or service: Difference between revisions

Content added Content deleted
Line 34: Line 34:
:::: Huh?
:::: Huh?
:::: First: daemons should be run from inittab or the rc directories which are run by init. If you don't do that, you lose your daemon on every reboot.
:::: First: daemons should be run from inittab or the rc directories which are run by init. If you don't do that, you lose your daemon on every reboot.
::::: yes--[[User:EMBee|eMBee]] 18:09, 17 November 2011 (UTC)
:::: Second: you could easily abstract the shell script:
:::: Second: you could easily abstract the shell script:
:::: <lang bash>$ cat >/usr/local/bin/detach_from_shell; chmod +x /usr/local/bin/detach_from_shell
:::: <lang bash>$ cat >/usr/local/bin/detach_from_shell; chmod +x /usr/local/bin/detach_from_shell
Line 45: Line 46:
fi</lang>
fi</lang>
:::: Now you have a shell command to run a program "as a daemon" without actually installing it on the system so that it runs reliably (e.g. so it comes back up after a reboot...)
:::: Now you have a shell command to run a program "as a daemon" without actually installing it on the system so that it runs reliably (e.g. so it comes back up after a reboot...)
::::: well, yes, except that this is very rare. to many services need special handling, extra arguments. some don't like their stdout redirected to /dev/null because they actually write something there, to the extent that it is rather hard to have one shell script to cover all. there is a reason why the sysv init has one shell script for each service.--[[User:EMBee|eMBee]] 18:09, 17 November 2011 (UTC)
:::: Meanwhile, if you are not running the program from the shell, there is no reason to detach it from the shell context. --[[User:Rdm|Rdm]] 17:50, 17 November 2011 (UTC)
:::: Meanwhile, if you are not running the program from the shell, there is no reason to detach it from the shell context. --[[User:Rdm|Rdm]] 17:50, 17 November 2011 (UTC)
::::: true. with a modern init system this is not needed, but it is nice to have the option and none of the arguments given here show that being able to detach from the terminal is inherently bad, nor has anyone yet explained that we shouldn't document capabilities that do exist. however all comments so far center on a solution which is outside of the scope of rosettacode because it has nothing to do with language comparison if we use a shellscript to solve the problem for any language. the shell solution will have its place in the [[Unix Shell]] section.--[[User:EMBee|eMBee]] 18:09, 17 November 2011 (UTC)