[Swift-commit] r5059 - usertools/persistent-coasters
wozniak at ci.uchicago.edu
wozniak at ci.uchicago.edu
Thu Sep 1 22:38:29 CDT 2011
Author: wozniak
Date: 2011-09-01 22:38:29 -0500 (Thu, 01 Sep 2011)
New Revision: 5059
Modified:
usertools/persistent-coasters/helpers.zsh
usertools/persistent-coasters/setup.sh
usertools/persistent-coasters/start-service.zsh
Log:
Improvements for use from other directories
Modified: usertools/persistent-coasters/helpers.zsh
===================================================================
--- usertools/persistent-coasters/helpers.zsh 2011-09-02 03:38:14 UTC (rev 5058)
+++ usertools/persistent-coasters/helpers.zsh 2011-09-02 03:38:29 UTC (rev 5059)
@@ -73,6 +73,30 @@
return 0
}
+# Timestamped log messages; may be disabled via LOGGING=NONE
+log()
+{
+ MSG=${*}
+ local -R 4 T=${SECONDS}
+ if [[ ${LOGGING} != "NONE" ]]
+ then
+ print "${T} ${MSG}"
+ fi
+}
+
+# Log a variable and value
+logvar()
+{
+ V=$1
+ MSG="${V}=${(P)V}"
+ log "$MSG"
+}
+
+logvars()
+{
+ for v in ${*} ; logvar ${v}
+}
+
nanos()
{
date +%s.%N
@@ -140,7 +164,7 @@
}
shoot_kv()
-{
+{
local VAR=$1
eval print -a -C 2 \"'${(kv)'$VAR'[@]}'\"
return 0
@@ -181,16 +205,16 @@
done
local RESULT=${UNITS[UNIT+1]}
- if [[ ${RESULT} == "B" ]]
+ if [[ ${RESULT} == "B" ]]
then
print "${BYTES} B"
- else
+ else
local -F BF=${BYTES}
local MANTISSA=$(( BF / (1024 ** UNIT ) ))
MANTISSA=$( significant ${LENGTH} ${MANTISSA} )
print "${MANTISSA} ${RESULT}"
fi
-
+
return 0
}
@@ -206,7 +230,7 @@
local LZ=1 # Leading zeros
local C
local i=1
- while (( 1 ))
+ while (( 1 ))
do
C=${FLOAT[i]}
[[ ${C} != "0" ]] && [[ ${C} != "." ]] && break
@@ -214,11 +238,11 @@
RESULT+=${C}
(( i++ ))
done
- while (( ${DIGITS} > 0 ))
+ while (( ${DIGITS} > 0 ))
do
C=${FLOAT[i]}
- if [[ ${C} == "" ]]
- then
+ if [[ ${C} == "" ]]
+ then
(( ! DOT )) && RESULT+="." && DOT=1
C="0"
fi
@@ -228,7 +252,7 @@
(( DIGITS-- ))
done
if (( ! DOT )) # Extra zeros to finish out integer
- then
+ then
local -i J=${NUMBER}
# J=${J}
while (( ${#RESULT} < ${#J} ))
Modified: usertools/persistent-coasters/setup.sh
===================================================================
--- usertools/persistent-coasters/setup.sh 2011-09-02 03:38:14 UTC (rev 5058)
+++ usertools/persistent-coasters/setup.sh 2011-09-02 03:38:29 UTC (rev 5059)
@@ -6,11 +6,11 @@
export WORK
-${TOOLS}/gensites.sh ${WORK} sites.passivate-template.xml \
+${TOOLS}/gensites.sh ${WORK} ${PC}/sites.passivate-template.xml \
sites.passivate.xml
[[ $? != 0 ]] && bail "sites problem (passivate)" && return
-${TOOLS}/gensites.sh ${WORK} sites.persistent.xml sites.xml
+${TOOLS}/gensites.sh ${WORK} ${PC}/sites.persistent.xml sites.xml
[[ $? != 0 ]] && bail "sites problem (persistent)" && return
return 0
Modified: usertools/persistent-coasters/start-service.zsh
===================================================================
--- usertools/persistent-coasters/start-service.zsh 2011-09-02 03:38:14 UTC (rev 5058)
+++ usertools/persistent-coasters/start-service.zsh 2011-09-02 03:38:29 UTC (rev 5059)
@@ -29,28 +29,19 @@
SWIFT_OUT=${PWD}/swift.out
-# Timestamped log messages; may be disabled via PC_LOGGING
-log()
-{
- MSG=${*}
- local -R 4 T=${SECONDS}
- if [[ ${PC_LOGGING} != "NONE" ]]
- then
- print "${T} ${MSG}"
- fi
-}
+logvars PC COASTER_SERVICE WORKER_LOGDIR
# Get the function start-workers() from one of these files:
log $( declare WORKER_MODE )
if [[ ${WORKER_MODE} == "local" ]]
then
- source workers-local.zsh
+ source ${PC}/workers-local.zsh
elif [[ ${WORKER_MODE} == "ssh" ]]
then
- source workers-ssh.zsh
+ source ${PC}/workers-ssh.zsh
elif [[ ${WORKER_MODE} == "cobalt" ]]
then
- source workers-cobalt.zsh
+ source ${PC}/workers-cobalt.zsh
else
print "Unknown WORKER_MODE: ${WORKER_MODE}"
false
@@ -131,16 +122,17 @@
log "Coaster service on: ${SERVICE_COASTERS}"
WORK=${WORKER_WORK}
-source setup.sh
+source ${PC}/setup.sh
exitcode "setup.sh failed!"
sleep 1
log "Passivate..."
-{ ${SWIFT} -config swift.properties \
- -sites.file sites.passivate.xml \
- -tc.file tc.passivate.data \
- passivate.swift < /dev/null >& ${SWIFT_OUT}
+{ ${SWIFT} \
+ -config ${PC}/swift.properties \
+ -sites.file sites.passivate.xml \
+ -tc.file ${PC}/tc.passivate.data \
+ ${PC}/passivate.swift < /dev/null >& ${SWIFT_OUT}
exitcode "Swift failed!"
print "Swift finished."
} &
@@ -163,7 +155,7 @@
cp sites.passivate.xml sites.xml
log "Created user sites file: sites.xml"
-cp tc.passivate.data tc.data
-log "Created user tc file: tc.data"
+# cp tc.passivate.data tc.data
+# log "Created user tc file: tc.data"
exit 0
More information about the Swift-commit
mailing list