Skip to content

Commit

Permalink
Add some extra logs to recceiver
Browse files Browse the repository at this point in the history
  • Loading branch information
jacomago committed Apr 3, 2024
1 parent e8cbcaf commit a9fc21e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
3 changes: 2 additions & 1 deletion server/recceiver/announce.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ def __init__(self, tcpport, key=0,
raise RuntimeError('Announce list is empty at start time...')

def startProtocol(self):
_log.info('setup Announcer')
_log.info('Setup Announcer')
self.D = self.reactor.callLater(0, self.sendOne)
# we won't process any receieved traffic, so no reason to wake
# up for it...
self.transport.pauseProducing()

def stopProtocol(self):
_log.info('Stop Announcer')
self.D.cancel()
del self.D

Expand Down
8 changes: 5 additions & 3 deletions server/recceiver/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
from .announce import Announcer
from .processors import ProcessorController

_log = logging.getLogger(__name__)

class Log2Twisted(logging.StreamHandler):
"""Print logging module stream to the twisted log
"""
Expand Down Expand Up @@ -65,7 +67,7 @@ def __init__(self, config):

def privilegedStartService(self):

print('Starting')
_log.info('Starting RecService')

# Start TCP server on random port
self.tcpFactory = CastFactory()
Expand All @@ -87,7 +89,7 @@ def privilegedStartService(self):

# Find out which port is in use
addr = self.tcp.getHost()
print('listening on',addr)
_log.info('RecService listening on ', addr)

self.key = random.randint(0,0xffffffff)

Expand Down Expand Up @@ -138,7 +140,7 @@ def makeService(self, opts):
lvl = logging.WARN
else:
if not isinstance(lvl, (int, )):
print("Invalid loglevel", lvlname)
_log.info("Invalid loglevel", lvlname)
lvl = logging.WARN

fmt = conf.get('logformat', "%(levelname)s:%(name)s %(message)s")
Expand Down
11 changes: 7 additions & 4 deletions server/recceiver/cfstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,15 @@ def _startServiceWithLock(self):
self.clean_service()

def stopService(self):
_log.info('CF_STOP')
service.Service.stopService(self)
return self.lock.run(self._stopServiceWithLock)

def _stopServiceWithLock(self):
# Set channels to inactive and close connection to client
if self.conf.getboolean('cleanOnStop', True):
self.clean_service()
_log.info("CF_STOP")
_log.info("CF_STOP with lock")

# @defer.inlineCallbacks # Twisted v16 does not support cancellation!
def commit(self, transaction_record):
Expand Down Expand Up @@ -321,6 +322,8 @@ def dict_to_file(dict, iocs, conf):


def __updateCF__(proc, pvInfoByName, delrec, hostName, iocName, iocid, owner, iocTime):
_log.info("CF Update IOC: %s", iocid)

# Consider making this function a class methed then 'proc' simply becomes 'self'
client = proc.client
channels_dict = proc.channel_dict
Expand Down Expand Up @@ -512,7 +515,7 @@ def __updateCF__(proc, pvInfoByName, delrec, hostName, iocName, iocid, owner, io
u'owner': owner,
u'properties': alProps})
_log.debug("Add new alias: %s", channels[-1])
_log.info("Total channels to update: %s", len(channels))
_log.info("Total channels to update: %s %s", len(channels), iocName)
if len(channels) != 0:
client.set(channels=channels)
else:
Expand Down Expand Up @@ -546,7 +549,7 @@ def prepareFindArgs(conf, args):


def poll(update, proc, pvInfoByName, delrec, hostName, iocName, iocid, owner, iocTime):
_log.debug("Polling begins...")
_log.info("Polling %s begins...", iocName)
sleep = 1
success = False
while not success:
Expand All @@ -560,4 +563,4 @@ def poll(update, proc, pvInfoByName, delrec, hostName, iocName, iocid, owner, io
#_log.debug(str(channels_dict))
time.sleep(min(60, sleep))
sleep *= 1.5
_log.debug("Polling complete")
_log.info("Polling %s complete", iocName)
8 changes: 8 additions & 0 deletions server/recceiver/dbstore.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-

import itertools
import logging

from zope.interface import implementer

Expand All @@ -10,6 +11,8 @@

from . import interfaces

_log = logging.getLogger(__name__)

__all__ = ['DBProcessor']

@implementer(interfaces.IProcessor)
Expand Down Expand Up @@ -37,6 +40,7 @@ def waitFor(self, D):
return D

def startService(self):
_log.info("Start DBService")
service.Service.startService(self)

# map of source id# to server table id keys
Expand Down Expand Up @@ -64,6 +68,8 @@ def startService(self):
self.waitFor(self.pool.runInteraction(self.cleanupDB))

def stopService(self):
_log.info("Stop DBService")

service.Service.stopService(self)

self.waitFor(self.pool.runInteraction(self.cleanupDB))
Expand All @@ -73,6 +79,8 @@ def stopService(self):
return defer.DeferredList(list(self.Ds), consumeErrors=True)

def cleanupDB(self, cur):
_log.info("Cleanup DBService")

assert self.mykey != 0
cur.execute('PRAGMA foreign_keys = ON;')
cur.execute('DELETE FROM %s WHERE owner=?' % self.tserver,
Expand Down

0 comments on commit a9fc21e

Please sign in to comment.