X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=nm.py;h=c4760fcc6ec848a7c7c37981120ce6a6b97254a5;hb=c50b76ac34dc007a5f63ae8ff72bc6d2aa7d2166;hp=23f5edceadeb0b328b975c6d11cd6834c0c099b1;hpb=261dbf8d44fa2721bcad8855f292faec66433477;p=nodemanager.git diff --git a/nm.py b/nm.py index 23f5edc..c4760fc 100644 --- a/nm.py +++ b/nm.py @@ -7,12 +7,17 @@ import time import xmlrpclib import socket import os +import sys +import resource import logger import tools from config import Config -from plcapi import PLCAPI +from plcapi import PLCAPI + + +savedargv = sys.argv[:] parser = optparse.OptionParser() parser.add_option('-d', '--daemon', action='store_true', dest='daemon', default=False, help='run daemonized') @@ -26,9 +31,13 @@ modules = [] def GetSlivers(plc): data = plc.GetSlivers() + # net needs access to API for i2 nodes. for module in modules: - callback = getattr(module, 'GetSlivers') - callback(data) + if module.__name__ == 'net': + module.GetSlivers(plc, data) + else: + callback = getattr(module, 'GetSlivers') + callback(data) def run(): try: @@ -46,7 +55,7 @@ def run(): print "Warning while writing PID file:", err # Load and start modules - for module in ['net', 'proper', 'conf_files', 'sm']: + for module in ['net', 'proper', 'conf_files', 'sm', 'bwmon']: try: m = __import__(module) m.start(options, config) @@ -70,7 +79,15 @@ def run(): except: logger.log_exc() -if __name__ == '__main__': run() +if __name__ == '__main__': + stacklim = 512*1024 # 0.5 MiB + curlim = resource.getrlimit(resource.RLIMIT_STACK)[0] # soft limit + if curlim > stacklim: + resource.setrlimit(resource.RLIMIT_STACK, (stacklim, stacklim)) + # for some reason, doesn't take effect properly without the exec() + python = '/usr/bin/python' + os.execv(python, [python] + savedargv) + run() else: # This is for debugging purposes. Open a copy of Python and import nm tools.as_daemon_thread(run)