LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-19-2015, 06:35 PM   #1
okram_
LQ Newbie
 
Registered: Jan 2013
Location: cloud
Posts: 12

Rep: Reputation: Disabled
python app service failed to start


Here is the /etc/init.d/xyz script http://pastebin.com/02G5tpgH

Whenever the service is stopped and started via the Capistrano2, the service will not start. The Capistrano2 uses a user that have the sudo access. This is what it returns while checking the service status.

Process dead but pidfile exists

For some reason the start script is not starting the service/daemon. Below is the start script (from the http://pastebin.com/02G5tpgH )


PHP Code:
DIR=/opt/mount/xyz/current/src
DAEMON
=$DIR/main.py
DAEMON_NAME
=xyz
PYTHON
=/usr/local/bin/python2.7
DAEMON_OPTS
="--port=8080 --debug --log_file_prefix=/opt/mount/xyz/logs/xyz --log_file_max_size=1000000 --env=stage"
DAEMON_USER=python
LOGFILE
="/opt/mount/xyz/logs/error.log"
LOGPATH=$(dirname $LOGFILE)
PIDFILE=/var/run/$DAEMON_NAME.pid
 
 
case "$1" in
start
)
        
printf "%-50s" "Starting $DAEMON_NAME..."
        
cd $DIR
        
[ -d $LOGPATH ] || mkdir $LOGPATH
  
[ -f $LOGFILE ] || su $DAEMON_USER -'touch $LOGFILE'
        
PID=`$PYTHON $DAEMON $DAEMON_OPTS > $LOGFILE  2>&1 & echo $!`
        
#echo "Saving PID" $PID " to " $PIDFILE
        
if [ -z $PID ]; then
            printf 
"%s\n" "Fail"
        
else
            echo 
$PID $PIDFILE
            printf 
"%s\n" "Ok"
        
fi
;; 
Everything works just find, if i have to go in and execute

PHP Code:
service xyz stop
service xyz start
service xyz status 
 
Old 05-21-2015, 03:39 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,838

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
there are some strange constructs in this script, for example you read the content of $PIDFILE before checking if exists (line 52). Also line 28 (PID=...) is a bit unusual.
But anyway, if you want to find the reason I suggest you to put set -xv at the beginning of the script and check the logfile and you will see what was happened.
 
  


Reply

Tags
environment variables, init script, python



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
[SOLVED] service httpd start [FAILED] tennis_slacker Linux - Server 3 05-28-2019 01:45 AM
Service Squid start failed yanto Linux - Newbie 8 04-11-2012 04:37 PM
http service failed to start eboy98 Linux - Server 7 04-02-2010 11:58 AM
Failed to emerge app-admin/python-updater-0.7-r1 godi Gentoo 2 02-22-2010 04:21 AM
when i try to start samba pdc's smb service nmbd failed to start . sandeepchau123 Linux - Newbie 2 10-20-2007 01:59 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:35 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