Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions liveMonitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
from sendToLive import uploadOneEvent
import datetime
import logging
from RMS.Logger import initLogging
import RMS.ConfigReader as cr
from stat import ST_INO
from uploadToArchive import readKeyFile, readIniFile
from ukmonPostProc import setupLogging


log = logging.getLogger("logger")
log = logging.getLogger()

timetowait = 30 # seconds to wait for a new line before deciding the log is stale

Expand Down Expand Up @@ -54,12 +54,11 @@ def monitorLogFile(camloc, rmscfg):
"""
cfg = cr.parse(os.path.expanduser(rmscfg))


log = logging.getLogger("logger")
while len(log.handlers) > 0:
log.removeHandler(log.handlers[0])

initLogging(cfg, 'ukmonlive_')
datadir = cfg.data_dir
logdir = os.path.expanduser(os.path.join(datadir, cfg.log_dir))

setupLogging(logdir, 'ukmonlive_')

log.info('--------------------------------')
log.info(' live feed started')
log.info('--------------------------------')
Expand All @@ -79,8 +78,6 @@ def monitorLogFile(camloc, rmscfg):
log.error('config file not present, aborting')
exit(1)

datadir = cfg.data_dir
logdir = os.path.expanduser(os.path.join(datadir, cfg.log_dir))
keepon = True
logf = ''
capdir = ''
Expand Down
2 changes: 1 addition & 1 deletion refreshTools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ if [[ "$LOCATION" != "NOTCONFIGURED" && "$LOCATION" != "" ]] ; then
loopctr=0
echo "Checking RMS update not in progress"
while [ $loopctr -lt 10 ] ; do
grep XX0001 $RMSCFG
grep XX0001 $RMSCFG | grep stationID:
[ $? -eq 1 ] && break
echo "RMS update in progress or station not configured, trying again in a minute"
sleep 60
Expand Down
18 changes: 17 additions & 1 deletion ukmonPostProc.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

import os
import sys
import glob
import time

import Utils.BatchFFtoImage as bff2i
import Utils.GenerateMP4s as gmp4
Expand Down Expand Up @@ -46,10 +48,22 @@ def setupLogging(logpath, prefix):
log.addHandler(ch)

log.setLevel(logging.INFO)

purgeOldLogs(logdir, prefix)

log.info('logging initialised')
return


def purgeOldLogs(logdir, logpref, days=30):
reftime = time.time() - 86400*days
for logf in glob.glob(os.path.join(logdir, logpref + '*.log*')):
if os.path.getmtime(logf) < reftime:
log.debug('removing old log', logf)
os.remove(logf)
return


def rmsExternal(cap_dir, arch_dir, config):
""" Called from RMS to trigger the UKMON specific code

Expand Down Expand Up @@ -108,8 +122,9 @@ def rmsExternal(cap_dir, arch_dir, config):
log.info('uploading remaining files to archive')
uploadToArchive(arch_dir, keys=keys)

# do not remote reboot lock file if running another script
# do not remove reboot lock file if running another script
# os.remove(rebootlockfile)

extrascrfn = os.path.join(myloc, 'extrascript')
if os.path.isfile(extrascrfn):
extrascript = open(extrascrfn,'r').readline().strip()
Expand All @@ -129,6 +144,7 @@ def rmsExternal(cap_dir, arch_dir, config):
log.info('unable to remove reboot lock file, pi will not reboot')
pass

log.info('done')
# clear log handlers again
while len(log.handlers) > 0:
log.removeHandler(log.handlers[0])
Expand Down
Loading