[JIRA] Commented: (CC-1009) Currupt cc.pid

"Dan Rollo (JIRA)" <[email protected]> Sat, 12 Feb 2011 02:36:03 -0600 (CST)
Newsgroups gmane.comp.java.cruise-control.devel
Message-ID <1540591648.1297499763124.JavaMail.root@chidmzhosting02.thoughtworks.com>
    [ http://jira.public.thoughtworks.org/browse/CC-1009?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_19073 ] 

Dan Rollo commented on CC-1009:
-------------------------------

Hi John,

Just found your email with some script changes, but my shell script skills are limited. The last email I saw from you had the following:

http://thread.gmane.org/gmane.comp.java.cruise-control.devel/12643/focus=12679

From: John Patrick <nhoj.patrick <at> gmail.com>
Subject: Re: Getting a Patch Included [CC-1009]
Newsgroups: gmane.comp.java.cruise-control.devel
Date: 2010-12-19 12:46:07 GMT (7 weeks, 5 days, 19 hours and 11 minutes ago)

Take 2... my fault.

I was testing it on MacOSX, but indirectly using the example script below.

I tried it;
without a cc.pid
with an empty cc.pid
invalid pid in cc.pid
valid pid for bash in cc.pid

----
#!/usr/bin/env bash

## single instance per cc.pid
# 1) use ${CC_PID} is already defined
# 2) default ${PID} to -1 and attempt to read pid from ${CC_PID}
# 3) check ${PID} is not stale
if [ ! "${CC_PID}" ]; then
    CC_PID=cc.pid
fi
PID_INVALID="000000"
PID=${PID_INVALID}
if [ -f "${CC_PID}" ]; then
    PID=`head -1 ${CC_PID}`
    if [[ ${PID} != *[[:digit:]]*  ]]; then
        PID=${PID_INVALID}
    fi
fi
RUNNING=`ps -ef | grep "${PID}" | grep -v grep | grep bash | wc -l | sed "s| ||g"`
if [ "${RUNNING}" != "0" ]; then
    echo "CruiseControl already running"
    exit -1
fi

EXEC="echo hello"
echo $EXEC
$EXEC &
echo $! > ${CC_PID}
cat cc.pid
-----

John
-------------------------------


I noticed a few differences between that email and the latest patch attached to the JIRA CC-1009:

1. The new PID_INVALID="000000" (cool, and I also would change the comment: 
# 2) default ${PID} to 000000 and attempt to read pid from ${CC_PID}


2. The check between:
if [ -f "${CC_PID}" ]; then
and...
RUNNING=`ps -ef | grep "${PID}" | grep -v grep | grep bash | wc -l | sed "s| ||g"`


I'm not really sure which script you're intending to be used (and/or if the snippet changes in the latest email where just for testing). Could you please build a new patch with the "real" script logic and attach it to the JIRA?

Thanks!
Dan


> Currupt cc.pid
> --------------
>
>                 Key: CC-1009
>                 URL: http://jira.public.thoughtworks.org/browse/CC-1009
>             Project: CruiseControl
>          Issue Type: Bug
>    Affects Versions: 2.8.4
>         Environment: Unix
>            Reporter: John Patrick
>            Priority: Major
>         Attachments: cc-1009.patch, cc-1009.patch-r4568
>
>   Original Estimate: 0 minutes
>  Remaining Estimate: 0 minutes
>
> The current cruisecontrol.sh, does not check if the current value in cc.pid is of an currently active cruisecontrol instance.
> If you execute cruisecontrol.sh again, it overwrites cc.pid.
> I've already done a patch, that will check cc.pid and kill the start if the cc.pid is an active cruisecontrol instance that is already running.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.public.thoughtworks.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb