def runSingleServerInstanceNoNat(): # Parse arguments args = parser.parse_args() sys.path.append(os.getcwd()) # Load config conf = args.configFile if conf[-3:] == '.py': conf = conf[:-3] print(conf) cfg = importlib.import_module(conf) app = MMPRaytracer('localhost') # Creates deamon, register the app in it daemon = Pyro4.Daemon(host=cfg.server, port=cfg.serverPort) uri = daemon.register(app) # Get nameserver ns = Pyro4.locateNS(host=cfg.nshost, port=cfg.nsport, hmac_key=cfg.hkey) # Register app ns.register(cfg.appName, uri) print(uri) # Deamon loops at the end daemon.requestLoop()
def runSingleServerInstance(): ''' Run a single instance of the Tracer server. The configuration file given in args must include the following: server, serverPort, serverNathost, serverNatport, nshost, nsport, appName, hkey ''' # Parse arguments args = parser.parse_args() sys.path.append(os.getcwd()) # Load config conf = args.configFile if conf[-3:] == '.py': conf = conf[:-3] print(conf) cfg = importlib.import_module(conf) app = MMPRaytracer('localhost') PyroUtil.runAppServer(cfg.server, cfg.serverPort, cfg.serverNathost, cfg.serverNatport, cfg.nshost, cfg.nsport, cfg.appName, cfg.hkey, app=app)
# that logs at the INFO-level. Use this place to set for debug level. logging.config.fileConfig('../../loggingNew.conf') logger = logging.getLogger('mmpraytracer') print("#######################################") print("######### Active Logging info #########") logger.debug('messages will be logged') logger.info('messages will be logged') logger.warn('messages will be logged') logger.error('messages will be logged') logger.critical('messages will be logged') print("#######################################") # Initialise apps mieApp = MMPMie('localhost') tracerApp = MMPRaytracer('localhost') comsolApp = MMPComsolDummy('localhost') # Set default LED json tracerApp.setDefaultInputFile('../../DefaultLED.json') # Connect functions pScat = mieApp.getProperty(PropertyID.PID_ScatteringCrossSections, 0, objectID=objID.OBJ_PARTICLE_TYPE_1) pPhase = mieApp.getProperty(PropertyID.PID_InverseCumulativeDist, 0, objectID=objID.OBJ_PARTICLE_TYPE_1) tracerApp.setProperty(pScat) tracerApp.setProperty(pPhase)
def runSingleServerInstanceSSHtunnel(): # Parse arguments args = parser.parse_args() sys.path.append(os.getcwd()) # Load config conf = args.configFile if conf[-3:] == '.py': conf = conf[:-3] print(conf) cfg = importlib.import_module(conf) # Load the App app = MMPRaytracer('localhost') # Prepare ssh tunnels pyroTunnel = SshTunnel(localport=cfg.serverPort, remoteport=cfg.serverPort, remoteuser=cfg.hostUserName, remotehost=cfg.server, reverse=True) nsTunnel = SshTunnel(localport=cfg.nsport, remoteport=cfg.nsport, remoteuser=cfg.hostUserName, remotehost=cfg.nshost, reverse=False) try: # Open tunnels pyroTunnel.run() nsTunnel.run() sleep(1) # Creates deamon, register the app in it daemon = Pyro4.Daemon(host='localhost', port=cfg.serverPort) uri = daemon.register(app) print(uri) # Get nameserver ns = Pyro4.locateNS(host='localhost', port=cfg.nsport, hmac_key=cfg.hkey) # Register app ns.register(cfg.appName, uri) print(uri) # Shutdown handler. Remember to close ssh tunnels def signal_handler(signal, frame): print('Shutting down!') pyroTunnel.terminate() nsTunnel.terminate() sys.exit(0) signal.signal(signal.SIGINT, signal_handler) # Deamon loops at the end daemon.requestLoop() except: pyroTunnel.terminate() nsTunnel.terminate() print('terminated') raise