pidfile = open(options.pidfile, 'w') pidfile.write(str(os.getpid())) pidfile.close() def shutdown(): if os.path.exists(options.pidfile): os.unlink(options.pidfile) atexit.register(shutdown) logToDir(options.logdir) # Configure application components metricReceived.installHandler(receiver.process) startListener(settings.LINE_RECEIVER_INTERFACE, settings.LINE_RECEIVER_PORT, MetricLineReceiver) startListener(settings.PICKLE_RECEIVER_INTERFACE, settings.PICKLE_RECEIVER_PORT, MetricPickleReceiver) client.connect(settings.DESTINATION_HOST, settings.DESTINATION_PORT) startRecording() # Run the twisted reactor print "%s running with pid %d" % (program, os.getpid()) if options.profile: import cProfile if exists(options.profile): os.unlink(options.profile)
def shutdown(): if os.path.exists(options.pidfile): os.unlink(options.pidfile) atexit.register(shutdown) if settings.USER: pwent = pwd.getpwnam(settings.USER) os.chown(options.pidfile, pwent.pw_uid, pwent.pw_gid) print "Dropping privileges to become the user %s" % settings.USER dropprivs(settings.USER) # Configure application components metricReceived.installHandler(MetricCache.store) startListener(settings.LINE_RECEIVER_INTERFACE, settings.LINE_RECEIVER_PORT, MetricLineReceiver) startListener(settings.PICKLE_RECEIVER_INTERFACE, settings.PICKLE_RECEIVER_PORT, MetricPickleReceiver) startListener(settings.CACHE_QUERY_INTERFACE, settings.CACHE_QUERY_PORT, CacheQueryHandler) startWriter() startRecordingCacheMetrics() # Run the twisted reactor print "%s running" % program if options.profile: import cProfile if exists(options.profile): os.unlink(options.profile)
def shutdown(): if os.path.exists(pidfile): os.unlink(pidfile) atexit.register(shutdown) if settings.USER: pwent = pwd.getpwnam(settings.USER) os.chown(pidfile, pwent.pw_uid, pwent.pw_gid) dropprivs(settings.USER) logToDir(logdir) # Configure application components metricReceived.installHandler(MetricCache.store) startListener(settings.LINE_RECEIVER_INTERFACE, settings.LINE_RECEIVER_PORT, MetricLineReceiver) startListener(settings.PICKLE_RECEIVER_INTERFACE, settings.PICKLE_RECEIVER_PORT, MetricPickleReceiver) startListener(settings.CACHE_QUERY_INTERFACE, settings.CACHE_QUERY_PORT, CacheQueryHandler) if use_amqp: amqp_listener.startReceiver(amqp_host, amqp_port, amqp_user, amqp_password, vhost=amqp_vhost, spec=amqp_spec, exchange_name=amqp_exchange_name, verbose=amqp_verbose)
logToDir(options.logdir) pidfile = open(options.pidfile, 'w') pidfile.write( str(os.getpid()) ) pidfile.close() def shutdown(): if os.path.exists(options.pidfile): os.unlink(options.pidfile) atexit.register(shutdown) # Configure application components metricReceived.installHandler(relay) startListener(settings.LINE_RECEIVER_INTERFACE, settings.LINE_RECEIVER_PORT, MetricLineReceiver) startListener(settings.PICKLE_RECEIVER_INTERFACE, settings.PICKLE_RECEIVER_PORT, MetricPickleReceiver) if settings.RELAY_METHOD == 'rules': loadRules(options.rules) createClientConnections( allDestinationServers() ) elif settings.RELAY_METHOD == 'consistent-hashing': hosts = parseHostList(settings.CH_HOST_LIST) msg('consistent-hashing hosts = %s' % str(hosts)) setDestinationHosts(hosts) createClientConnections(hosts) startRecording() # Run the twisted reactor