Re: System V Init Script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Wed, 2009-06-03 at 10:29 +0100, James Bensley wrote:
> Hey Listees,
> 
> I have a question (hopefully quite simple) about the system V init
> scripts in /etc/init.d. I have an app installed and for some reason it
> had no system V init script. It has been installed a long while now so
> I can't quite remember whats going on but basically I remember I wrote
> the init script my self and the app is enabled as a service which
> chkconfig to run at system levels 3, 4 and 5. However when I wrote the
> script I only ever added a "start" and "stop" clause to it (why I
> can't remember?), now I need to add a "restart" clause but I'm having
> an issue. 
> 
> I have pasted the code below from my "restart" clause but from what I
> can tell, it is killing the app but not restarting it, I think because
> the killing process is still in action so when it start the app again
> it just gets killed straight away. If I enter "/etc/init.d/my_app
> restart" the app is terminated but does not start again, entering
> "/etc/init.d/my_app start" immediately after fires it up straight away
> so there is no problem there; can someone suggest a better way as my
> scripting is very begginnerish (if thats a word) and I don't doubt for
> a second I am doing this in a very inefficient manner:
> 
> <snipety snip snip>
> 
> restart)
> echo -n "Stopping my_app: "
> pgrep my_app | while read PIDS; do # I have chosen this method because
> my_app spawns various child processes 
> kill -9 $PIDS                                   # and they all need to
> DIE!  (Killing the parent process would kill the child processes
> done                                              # however there are
> actually two parent processes so this seems like a good idea?)
> echo -n "Starting my_app: "
> /usr/local/my_app/sbin/my_app_bin &
> exit $?
> ;;
> 
> <snip snap snorum>
---
Well from what I understand there is quit a debate on processes and
forking them. One is released from the shell when it is forked into the
background to release the process from the shell. This also seems to be
the method for daemons under linux/unix. At least that's what I'm told.

###############
def createDaemon():
    try:     #fork so parent can exit
    if       #first child
    try:     #fork second child and exit zombies
    if       #second child
else:
    os.exit
###############

JohnStanley

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux