aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Reyna <David.Reyna@windriver.com>2019-02-20 14:39:36 -0800
committerDavid Reyna <David.Reyna@windriver.com>2019-02-20 14:39:36 -0800
commit652a7ebc28edecbaac24a6fbb543544866037d29 (patch)
tree0b43d03a89b0315a7255ad2a0755c4daf12b47c2
parent418f3dd3c2c2abad419246dfb1c851a85b5c3e8c (diff)
downloadsrtool-652a7ebc28edecbaac24a6fbb543544866037d29.tar.gz
srtool-652a7ebc28edecbaac24a6fbb543544866037d29.tar.bz2
srtool-652a7ebc28edecbaac24a6fbb543544866037d29.zip
srtool_update: improve update reporting and scheduling
Track the current running update task in ".srtupdate.task" to help track background update activity and overhead. Make calls to the update start/stop absolute paths to help track active SRTool tasks, especially between multiple servers. Signed-off-by: David Reyna <David.Reyna@windriver.com>
-rwxr-xr-xbin/common/srtool_update.py18
-rwxr-xr-xbin/dev_tools/tail.sh2
-rwxr-xr-xbin/srt4
3 files changed, 20 insertions, 4 deletions
diff --git a/bin/common/srtool_update.py b/bin/common/srtool_update.py
index ec8554ea..1ec6c0a3 100755
--- a/bin/common/srtool_update.py
+++ b/bin/common/srtool_update.py
@@ -40,6 +40,7 @@ master_log = ''
srtDbName = 'srt.sqlite'
UPDATE_STATUS_LOG = 'update_logs/update_status.log'
SRT_UPDATE_PID_FILE = '.srtupdate.pid'
+SRT_UPDATE_TASK_FILE = '.srtupdate.task'
#################################
# Common routines
@@ -193,11 +194,18 @@ def run_updates(force_all,name_filter,is_trial):
print("Update required\t...\texecuting '%s'" % (source[ORM.DATASOURCE_UPDATE]))
status_str += " > EXECUTE: execute '%s'\n" % (source[ORM.DATASOURCE_UPDATE])
- master_write("SRTOOL_UPDATE:%s:%s:%s\n" %(time_now.strftime(ORM.DATASOURCE_DATETIME_FORMAT),source[ORM.DATASOURCE_DESCRIPTION],source[ORM.DATASOURCE_UPDATE]))
+ master_write("SRTOOL_UPDATE:%s:%s:%s\n" %(datetime.now().strftime(ORM.DATASOURCE_DATETIME_FORMAT),source[ORM.DATASOURCE_DESCRIPTION],source[ORM.DATASOURCE_UPDATE]))
update_command = source[ORM.DATASOURCE_UPDATE]
if force_all:
update_command += " --force"
- os.system(os.path.join(script_pathname, update_command))
+ if update_command.startswith('./'):
+ update_command = os.path.join(script_pathname, update_command)
+ os.system("echo 'Update:%s,%s' > %s" % (datetime.now().strftime(ORM.DATASOURCE_DATETIME_FORMAT),update_command,os.path.join(script_pathname,SRT_UPDATE_TASK_FILE)))
+ os.system(update_command)
+ os.system("echo 'Done:%s,%s' >> %s" % (datetime.now().strftime(ORM.DATASOURCE_DATETIME_FORMAT),update_command,os.path.join(script_pathname,SRT_UPDATE_TASK_FILE)))
+ master_write("SRTOOL_UPDATE_DONE:%s:%s:%s\n" %(datetime.now().strftime(ORM.DATASOURCE_DATETIME_FORMAT),source[ORM.DATASOURCE_DESCRIPTION],source[ORM.DATASOURCE_UPDATE]))
+ # Take a breath, let any commits settle
+ time.sleep(10)
conn.close()
@@ -252,15 +260,20 @@ def list():
def cron_start():
pid = os.getpid()
master_write("SRTOOL_UPDATE:%s:Starting -v update cron job, pid=%s\n" % (datetime.now().strftime(ORM.DATASOURCE_DATETIME_FORMAT),pid))
+ os.system("echo 'Start:%s,<cron_start>' > %s" % (datetime.now().strftime(ORM.DATASOURCE_DATETIME_FORMAT),os.path.join(script_pathname,SRT_UPDATE_TASK_FILE)))
# Preserve this app's pid
srt_update_pid_file = os.path.join(script_pathname,SRT_UPDATE_PID_FILE)
with open(srt_update_pid_file, 'w') as pidfile:
pidfile.write("%s" % pid)
+ # Start with delay to allow SRTool to bootup
+ time.sleep(30)
+
# Loop until app is killed
extra_line = False
while True:
+ # Run the updates
run_updates(False,'all',False)
# Toggle an extra line in the log to make updates obvious
if extra_line:
@@ -282,6 +295,7 @@ def cron_stop():
os.system("kill %s" % pid)
os.system("rm %s" % srt_update_pid_file)
master_write("SRTOOL_UPDATE:%s:Stopping -^ update cron job, pid=%s\n" % (datetime.now().strftime(ORM.DATASOURCE_DATETIME_FORMAT),pid))
+ os.system("echo 'Done:%s,<cron_stop>' > %s" % (datetime.now().strftime(ORM.DATASOURCE_DATETIME_FORMAT),os.path.join(script_pathname,SRT_UPDATE_TASK_FILE)))
else:
print("No running update task file found")
diff --git a/bin/dev_tools/tail.sh b/bin/dev_tools/tail.sh
index f8d949a5..4c44cd47 100755
--- a/bin/dev_tools/tail.sh
+++ b/bin/dev_tools/tail.sh
@@ -19,4 +19,6 @@ echo "--- $SRTDBG_ERR_LOG --------------------"
tail $SRTDBG_ERR_LOG $CONTEXT
echo "--- $SRTDBG_LOG --------------------"
tail $SRTDBG_LOG $CONTEXT
+echo "--- Update Task --------------------"
+cat .srtupdate.task
diff --git a/bin/srt b/bin/srt
index 5b41693c..ac358d43 100755
--- a/bin/srt
+++ b/bin/srt
@@ -81,7 +81,7 @@ webserverKillAll()
# Stop the Update app
if [ 0 -eq $no_auto_update ] ; then
- ./bin/common/srtool_update.py --cron-stop
+ ${SRT_BASE_DIR}/bin/common/srtool_update.py --cron-stop
fi
}
@@ -116,7 +116,7 @@ webserverStartAll()
# Start the Update app
if [ 0 -eq $no_auto_update ] ; then
- ./bin/common/srtool_update.py --cron-start > /dev/null 2>&1 &
+ ${SRT_BASE_DIR}/bin/common/srtool_update.py --cron-start > /dev/null 2>&1 &
echo "SRTool update service started at PID $!"
fi
return $retval