mirror of https://github.com/apache/jclouds.git
Issue 126: started on nohup
git-svn-id: http://jclouds.googlecode.com/svn/trunk@2361 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
c98245a66c
commit
777202cec2
|
@ -0,0 +1,29 @@
|
||||||
|
:forget
|
||||||
|
SETLOCAL
|
||||||
|
set FOUND_PID=
|
||||||
|
set NEXT_MINUTE=
|
||||||
|
set INSTANCE_NAME=%1
|
||||||
|
shift
|
||||||
|
set SCRIPT=%1
|
||||||
|
shift
|
||||||
|
set LOG_DIR=%1
|
||||||
|
shift
|
||||||
|
CALL :findProcess %INSTANCE_NAME%
|
||||||
|
if defined FOUND_PID (
|
||||||
|
echo %INSTANCE_NAME% already running pid [%FOUND_PID%]
|
||||||
|
) else (
|
||||||
|
CALL :nextMinute
|
||||||
|
set _DATE=%DATE:~4%
|
||||||
|
set CMD=schtasks /create /sd %_DATE% /tn %INSTANCE_NAME% /ru System /tr "cmd /c title %INSTANCE_NAME%&%SCRIPT% >%LOG_DIR%\stdout.log 2>%LOG_DIR%\stderr.log" /sc:once /st %NEXT_MINUTE%
|
||||||
|
echo %INSTANCE_NAME% will start at %NEXT_MINUTE%
|
||||||
|
set SECONDS=%TIME:~6,2%
|
||||||
|
set /a SECOND=60-SECONDS
|
||||||
|
%CMD% >NUL
|
||||||
|
ping -n %SECONDS% 127.0.0.1 > NUL 2>&1
|
||||||
|
CALL :findProcess %INSTANCE_NAME%
|
||||||
|
if not defined FOUND_PID (
|
||||||
|
set EXCEPTION=%INSTANCE_NAME% did not start
|
||||||
|
abort
|
||||||
|
)
|
||||||
|
)
|
||||||
|
exit /b 0
|
|
@ -0,0 +1,20 @@
|
||||||
|
function forget {
|
||||||
|
unset FOUND_PID;
|
||||||
|
[ $# -eq 3 ] || {
|
||||||
|
abort "forget requires parameters INSTANCE_NAME SCRIPT LOG_DIR"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
local INSTANCE_NAME="$1"; shift
|
||||||
|
local SCRIPT="$1"; shift
|
||||||
|
local LOG_DIR="$1"; shift
|
||||||
|
mkdir -p $LOG_DIR
|
||||||
|
findPid $INSTANCE_NAME
|
||||||
|
[ -n "$FOUND_PID" ] && {
|
||||||
|
echo $INSTANCE_NAME already running pid [$FOUND_PID]
|
||||||
|
} || {
|
||||||
|
nohup $SCRIPT >$LOG_DIR/stdout.log 2>$LOG_DIR/stderr.log &
|
||||||
|
findPid $INSTANCE_NAME
|
||||||
|
[ -n "$FOUND_PID" ] || abort "$INSTANCE_NAME did not start"
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
:nextMinute
|
||||||
|
SETLOCAL
|
||||||
|
set HOURS=%TIME:~0,2%
|
||||||
|
set MINUTES=%TIME:~3,2%
|
||||||
|
|
||||||
|
set /a HOURS=%HOURS%
|
||||||
|
set /a MINUTES+=1
|
||||||
|
|
||||||
|
if %MINUTES% EQU 60 (set MINUTES=0&set /a HOURS+=1)
|
||||||
|
if %HOURS% EQU 24 (set HOURS=0)
|
||||||
|
|
||||||
|
if %HOURS% LSS 10 set HOURS=0%HOURS%
|
||||||
|
if %MINUTES% LSS 10 set MINUTES=0%MINUTES%
|
||||||
|
|
||||||
|
ENDLOCAL&SET NEXT_MINUTE=%HOURS%:%MINUTES%:00
|
||||||
|
exit /b 0
|
|
@ -0,0 +1,9 @@
|
||||||
|
:abort
|
||||||
|
CALL :findProcess %INSTANCE_NAME%
|
||||||
|
if defined _pid (
|
||||||
|
echo stopping %INSTANCE_NAME%
|
||||||
|
TASKKILL /F /T /PID %FOUND_PID% >NUL
|
||||||
|
)
|
||||||
|
schtasks /end /tn %INSTANCE_NAME% >NUL 2>NUL
|
||||||
|
schtasks /delete /tn %INSTANCE_NAME% /F >NUL 2>NUL
|
||||||
|
exit /b 0
|
Loading…
Reference in New Issue