LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-18-2007, 06:28 AM   #1
fahlen
LQ Newbie
 
Registered: Sep 2006
Posts: 3

Rep: Reputation: 0
dead but pid file exists


Hello,

I have created an init script for an application:

Code:
#!/bin/sh
#
# CServer.exe  
#
# chkconfig:   345 85 15
# description: 

### BEGIN INIT INFO
# Provides: elcorrectord
# Required-Start: $local_fs $network
# Required-Stop: 
# Should-Start: 
# Should-Stop: 
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: 
# Description: 
### END INIT INFO

# Source function library.
. /etc/rc.d/init.d/functions

exec="/usr/share/ElCorrector/Cotig/CServer.exe"
path="/usr/share/ElCorrector/Cotig"
prog="elcorrectord"
# config="<path to major config file>"

[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog

lockfile=/var/lock/subsys/$prog

start() {
    # [ -x $exec ] || exit 5
    # [ -f $config ] || exit 6
    echo -n $"Starting $prog: "
    # if not running, start it up here, usually something like "daemon $exec"
    cd $path
    /usr/bin/mono $exec -def -cfg -sil &
    retval=$?
    [ $retval -eq 0 ] && echo_success || echo_failure
    echo $! > /var/run/$prog.pid
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}

stop() {
    echo -n $"Stopping $prog: "
    # stop it here, often "killproc $prog"
    kill -9 `cat /var/run/$prog.pid`
    retval=$?
    [ $retval -eq 0 ] && echo_success || echo_failure
    rm -f /var/run/$prog.pid
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}

restart() {
    stop
    start
}

reload() {
    restart
}

force_reload() {
    restart
}

rh_status() {
    # run checks to determine if the service is running or use generic status
    status $prog
}

rh_status_q() {
    rh_status >/dev/null 2>&1
}


case "$1" in
    start)
        rh_status_q && exit 0
        $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    restart)
        $1
        ;;
    reload)
        rh_status_q || exit 7
        $1
        ;;
    force-reload)
        force_reload
        ;;
    status)
        rh_status
        ;;
    condrestart|try-restart)
        rh_status_q || exit 0
        restart
        ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|try-restart|reload|force-reload}"
        exit 2
esac
exit $?
I have also added this line to /etc/sudoers:
Code:
ALL	ALL = NOPASSWD: /sbin/service elcorrectord *
Now, if I from the terminal type "sudo /sbin/service elcorrectord start" or "sudo /sbin/service elcorrectord stop", everthing works fine.

However, if instead install a desktop file in the menu:
Code:
[Desktop Entry]
Encoding=UTF-8
Name=Start server
Exec=/usr/bin/sudo /sbin/service elcorrectord start
Icon=ElCorrector
Terminal=true
Type=Application
Categories=Qt;
... and also for stopping the server, then I start getting problems. I can then stop the server, but when ever I try to start the server and then execute "sudo /sbin/service elcorrectord status", I get the message:

elcorrectord dead but pid file exists


Has anyone run across this type of problem before? What to me appears so strange is that it works fine from the terminal, but when I execute the commands from the menu, stopping the server works, but starting it doesn't...

Last edited by fahlen; 12-18-2007 at 06:48 AM.
 
Old 12-18-2007, 09:14 AM   #2
fahlen
LQ Newbie
 
Registered: Sep 2006
Posts: 3

Original Poster
Rep: Reputation: 0
nohup did the trick. The started process was killed when the terminal was closed...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
squid dead but pid file exists chenboly Linux - Networking 3 05-31-2007 03:10 PM
exim dead but pid file exists File.am *BSD 2 03-22-2007 05:11 PM
ntpd dead but pid file exists wjn Linux - Networking 15 05-22-2005 01:32 PM
xinetd dead but pid file exists pas Linux - Newbie 2 01-21-2005 04:52 PM
nmbd dead but pid file exists mammajamma101 Linux - Newbie 2 01-14-2005 10:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:02 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration