本文整理汇总了Python中setproctitle.setproctitle函数的典型用法代码示例。如果您正苦于以下问题:Python setproctitle函数的具体用法?Python setproctitle怎么用?Python setproctitle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setproctitle函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: main
def main():
""" Main programm which is called when the clacks agent process gets started.
It does the main forking os related tasks. """
# Set process list title
os.putenv('SPT_NOENV', 'non_empty_value')
setproctitle("clacks-agent")
# Inizialize core environment
env = Environment.getInstance()
if not env.base:
env.log.critical("Clacks agent needs a 'core.base' do operate on")
exit(1)
env.log.info("Clacks %s is starting up (server id: %s)" % (VERSION, env.id))
if env.config.get('core.profile'):
import cProfile
import clacks.common.lsprofcalltree
p = cProfile.Profile()
p.runctx('mainLoop(env)', globals(), {'env': env})
#pylint: disable=E1101
k = clacks.common.lsprofcalltree.KCacheGrind(p)
data = open('prof.kgrind', 'w+')
k.output(data)
data.close()
else:
mainLoop(env)
开发者ID:gonicus,项目名称:clacks,代码行数:28,代码来源:main.py
示例2: main
def main():
from solarsan import logging
logger = logging.getLogger(__name__)
from solarsan.cluster.models import Peer
from solarsan.conf import rpyc_conn_config
from rpyc.utils.server import ThreadedServer
#from rpyc.utils.server import ThreadedZmqServer, OneShotZmqServer
from setproctitle import setproctitle
from .service import CLIService
import rpyc
title = 'SolarSan CLI'
setproctitle('[%s]' % title)
local = Peer.get_local()
cluster_iface_bcast = local.cluster_nic.broadcast
# Allow all public attrs, because exposed_ is stupid and should be a
# fucking decorator.
#t = ThreadedZmqServer(CLIService, port=18863,
#t = OneShotZmqServer(CLIService, port=18863,
t = ThreadedServer(CLIService, port=18863,
registrar=rpyc.utils.registry.UDPRegistryClient(ip=cluster_iface_bcast,
#logger=None,
logger=logger,
),
auto_register=True,
logger=logger,
#logger=None,
protocol_config=rpyc_conn_config)
t.start()
开发者ID:akatrevorjay,项目名称:solarsan,代码行数:30,代码来源:__init__.py
示例3: main
def main() -> None:
'''Runs server'''
# Parse options
define('production',
default = False,
help = 'run in production mode',
type = bool)
options.parse_command_line()
# Set server name
pname = settings.process_name if settings.process_name else None
if pname:
setproctitle(pname)
# Register IRC server
server = IRCServer(settings = ircdsettings)
for address, port in ircdsettings['listen']:
server.listen(port, address = address)
# Start profiling
if settings.profiling:
import yappi
yappi.start()
# Setup autoreload
autoreload.start()
# Run application
IOLoop.instance().start()
开发者ID:leandropls,项目名称:tornadoirc,代码行数:30,代码来源:server.py
示例4: __init__
def __init__(self,name=None,description=None,epilog=None,debug_flag=True,subcommands=False):
self.name = os.path.basename(sys.argv[0])
setproctitle('%s %s' % (self.name,' '.join(sys.argv[1:])))
signal.signal(signal.SIGINT, self.SIGINT)
reload(sys)
sys.setdefaultencoding('utf-8')
if name is None:
name = self.name
# Set to True to avoid any messages from self.message to be printed
self.silent = False
self.logger = Logger(self.name)
self.log = self.logger.default_stream
self.parser = argparse.ArgumentParser(
prog=name,
description=description,
epilog=epilog,
add_help=True,
conflict_handler='resolve',
)
if debug_flag:
self.parser.add_argument('--debug',action='store_true',help='Show debug messages')
if subcommands:
self.commands = {}
self.command_parsers = self.parser.add_subparsers(
dest='command', help='Please select one command mode below',
title='Command modes'
)
开发者ID:hile,项目名称:nosepicker,代码行数:33,代码来源:shell.py
示例5: init
def init(self):
global use_setproctitle
if use_setproctitle:
setproctitle("mongodb_log %s" % self.topic)
self.mongoconn = Connection(self.mongodb_host, self.mongodb_port)
self.mongodb = self.mongoconn[self.mongodb_name]
self.mongodb.set_profiling_level = SLOW_ONLY
self.collection = self.mongodb[self.collname]
self.collection.count()
self.queue.cancel_join_thread()
rospy.init_node(WORKER_NODE_NAME % (self.nodename_prefix, self.id, self.collname),
anonymous=False)
self.subscriber = None
while not self.subscriber:
try:
msg_class, real_topic, msg_eval = rostopic.get_topic_class(self.topic, blocking=True)
self.subscriber = rospy.Subscriber(real_topic, msg_class, self.enqueue, self.topic)
except rostopic.ROSTopicIOException:
print("FAILED to subscribe, will keep trying %s" % self.name)
time.sleep(randint(1,10))
except rospy.ROSInitException:
print("FAILED to initialize, will keep trying %s" % self.name)
time.sleep(randint(1,10))
self.subscriber = None
开发者ID:Jailander,项目名称:mongodb_store,代码行数:29,代码来源:mongodb_log.py
示例6: run_rule_async
def run_rule_async(rule_name, settings):
setproctitle("inferno - %s" % rule_name)
signal.signal(signal.SIGHUP, signal.SIG_IGN)
signal.signal(signal.SIGINT, signal.SIG_IGN)
signal.signal(signal.SIGTERM, signal.SIG_IGN)
rules = get_rules_by_name(
rule_name, settings['rules_directory'], immediate=False)
if rules and len(rules) > 0:
rule = rules[0]
else:
log.error('No rule exists with rule_name: %s' % rule_name)
raise Exception('No rule exists with rule_name: %s' % rule_name)
pid_dir = pid.pid_dir(settings)
log.info("Running %s" % rule.name)
try:
pid.create_pid(pid_dir, rule, str(os.getpid()))
execute_rule(rule, settings)
except Exception as e:
log.exception('%s: %s', rule_name, e)
if not rule.retry:
pid.create_last_run(pid_dir, rule)
else:
pid.create_last_run(pid_dir, rule)
finally:
pid.remove_pid(pid_dir, rule)
os._exit(0)
开发者ID:mkhaitman,项目名称:inferno,代码行数:28,代码来源:daemon.py
示例7: run
def run(self):
setproctitle("Event Handler")
self.do_recycle_proc = Recycle(terminator=self.terminator, recycle_period=self.recycle_period)
self.do_recycle_proc.start()
self.start_listen()
开发者ID:0-T-0,项目名称:copr,代码行数:7,代码来源:event_handle.py
示例8: run
def run(self):
self._name = "BuildActor-{0:d} job {1}".format(self.pid, self.job_id)
setproctitle.setproctitle('mob2_build')
logging.config.dictConfig(self._log_conf)
self._log = logging.getLogger(__name__)
#change the status to aware the job that this job is currently building
job = self.get_job()
job.status.state = Status.BUILDING
job.save()
self.make_job_environement(job)
os.chdir(job.dir)
#import data needed for the job
#build the cmdline??? seulement pour ClJob ???
#ou action generique de job et joue sur le polymorphism?
#perform data conversion
#how to decide which data must be convert?
# the acces log must record
# the submited jobs to mobyle
# or
# the submitted job to execution?
#
#acc_log = logging.getLogger( 'access')
#acc_log.info( "test access log {0}".format(self._name))
#the monitor is now aware of the new status
job.status.state = Status.TO_BE_SUBMITTED
job.save()
self._log.info( "{0} put job {1} with status {2} in table".format(self._name, job.id, job.status))
开发者ID:mobyle2,项目名称:mobyle2.exec_engine,代码行数:35,代码来源:build_actor.py
示例9: _set_process_title
def _set_process_title():
try:
import setproctitle
except ImportError:
pass
else:
setproctitle.setproctitle("kupfer")
开发者ID:engla,项目名称:kupfer,代码行数:7,代码来源:main.py
示例10: run
def run(self, debug=None):
"""
:param debug:
:return:
"""
self._validate_cmds()
if debug is not None:
self.debug = debug
if os.getenv(constants.WORKER_ENV_KEY) != 'true':
# 主进程
logger.info('Connect to server , debug: %s, workers: %s',
self.debug, self.spawn_count)
# 设置进程名
setproctitle.setproctitle(self._make_proc_name('worker:master'))
# 只能在主线程里面设置signals
self._handle_parent_proc_signals()
self._spawn_workers(self.spawn_count)
else:
# 子进程
setproctitle.setproctitle(self._make_proc_name('worker:worker'))
self._worker_run()
开发者ID:xubingyue,项目名称:shine,代码行数:25,代码来源:worker.py
示例11: ensure_running
def ensure_running( config ):
"""
Verify that there is an automount daemon servicing a mountpoint.
If there isn't, start one.
If we're configured to run in the foreground, this method never returns.
"""
mountpoint_dir = config['mountpoint_dir']
# is the daemon running?
procs = watchdog.find_by_attrs( "syndicate-automount-daemon", {"mounts": mountpoint_dir} )
if len(procs) > 0:
# it's running
print "Syndicate automount daemon already running for %s (PID(s): %s)" % (mountpoint_dir, ",".join( [str(watchdog.get_proc_pid(p)) for p in procs] ))
return True
if config.get("foreground", None):
main( config )
else:
logfile_path = None
pidfile_path = config.get("pidfile", None)
if config.has_key("logdir"):
logfile_path = os.path.join( config['logdir'], "syndicated.log" )
title = watchdog.attr_proc_title( "syndicate-automount-daemon", {"mounts" : mountpoint_dir} )
setproctitle.setproctitle( title )
daemon.daemonize( lambda: main(config), logfile_path=logfile_path, pidfile_path=pidfile_path )
return True
开发者ID:etherparty,项目名称:syndicate,代码行数:32,代码来源:syndicated.py
示例12: __init__
def __init__(self, name=None, description=None, epilog=None, debug_flag=True):
self.name = os.path.basename(sys.argv[0])
setproctitle('%s %s' % (self.name, ' '.join(sys.argv[1:])))
signal.signal(signal.SIGINT, self.SIGINT)
reload(sys)
sys.setdefaultencoding('utf-8')
if name is None:
name = self.name
# Set to True to avoid any messages from self.message to be printed
self.silent = False
self.logger = Logger(self.name)
self.log = self.logger.default_stream
self.subcommand_parser = None
self.parser = argparse.ArgumentParser(
prog=name,
description=description,
formatter_class=argparse.RawTextHelpFormatter,
epilog=epilog,
add_help=True,
conflict_handler='resolve',
)
if debug_flag:
self.parser.add_argument('--debug', action='store_true', help='Show debug messages')
self.parser.add_argument('--insecure', action='store_false', help='No HTTPS certificate validation')
self.parser.add_argument('-B', '--browser',
choices=('chrome','chromium','firefox'),
help='Browser for cookie stealing'
)
开发者ID:PanBen,项目名称:jsontester,代码行数:34,代码来源:shell.py
示例13: run
def run(self, *args, **kwargs):
"""
The Node main method, running in a child process (similar to Process.run() but also accepts args)
A children class can override this method, but it needs to call super().run(*args, **kwargs)
for the node to start properly and call update() as expected.
:param args: arguments to pass to update()
:param kwargs: keyword arguments to pass to update()
:return: last exitcode returned by update()
"""
# TODO : make use of the arguments ? since run is now the target for Process...
exitstatus = None # keeping the semantic of multiprocessing.Process : running process has None
if setproctitle and self.new_title:
setproctitle.setproctitle("{0}".format(self.name))
print('[{proc}] Proc started as [{pid}]'.format(proc=self.name, pid=self.ident))
with self.context_manager(*args, **kwargs) as cm:
if cm:
cmargs = maybe_tuple(cm)
# prepending context manager, to be able to access it from target
args = cmargs + args
exitstatus = self.eventloop(*args, **kwargs)
logging.debug("[{self.name}] Proc exited.".format(**locals()))
return exitstatus # returning last exit status from the update function
开发者ID:asmodehn,项目名称:pyzmp,代码行数:28,代码来源:coprocess.py
示例14: run
def run(self):
"""Runs the worker and consumes messages from RabbitMQ.
Returns only after `shutdown()` is called.
"""
# Lazy import setproctitle.
# There is bug with the latest version of Python with
# uWSGI and setproctitle combination.
# Watch: https://github.com/unbit/uwsgi/issues/1030
from setproctitle import setproctitle
setproctitle("kuyruk: worker on %s" % self.queue)
self._setup_logging()
signal.signal(signal.SIGINT, self._handle_sigint)
signal.signal(signal.SIGTERM, self._handle_sigterm)
signal.signal(signal.SIGHUP, self._handle_sighup)
signal.signal(signal.SIGUSR1, self._handle_sigusr1)
signal.signal(signal.SIGUSR2, self._handle_sigusr2)
self._started = os.times()[4]
for f in (self._watch_load, self._shutdown_timer):
t = threading.Thread(target=f)
t.daemon = True
t.start()
signals.worker_start.send(self.kuyruk, worker=self)
self._consume_messages()
signals.worker_shutdown.send(self.kuyruk, worker=self)
logger.debug("End run worker")
开发者ID:muraty,项目名称:kuyruk,代码行数:32,代码来源:worker.py
示例15: __init__
def __init__(self, stream, gate):
self.stream = stream
self.gate = gate
aj.master = False
os.setpgrp()
setproctitle.setproctitle(
'%s worker [%s]' % (
sys.argv[0],
self.gate.name
)
)
set_log_params(tag=self.gate.log_tag)
init_log_forwarding(self.send_log_event)
logging.info(
'New worker "%s" PID %s, EUID %s, EGID %s',
self.gate.name,
os.getpid(),
os.geteuid(),
os.getegid(),
)
self.context = Context(parent=aj.context)
self.context.session = self.gate.session
self.context.worker = self
self.handler = HttpMiddlewareAggregator([
AuthenticationMiddleware.get(self.context),
CentralDispatcher.get(self.context),
])
self._master_config_reloaded = Event()
开发者ID:HasClass0,项目名称:ajenti,代码行数:31,代码来源:worker.py
示例16: __init__
def __init__(self, config, runner, pilot_id, rpc=None, debug=False,
run_timeout=180, backoff_delay=1):
self.config = config
self.runner = runner
self.pilot_id = pilot_id
self.hostname = gethostname()
self.rpc = rpc
self.debug = debug
self.run_timeout = run_timeout
self.backoff_delay = backoff_delay
self.resource_interval = 1.0 # seconds between resouce measurements
self.running = True
self.tasks = {}
try:
setproctitle('iceprod2_pilot({})'.format(pilot_id))
except Exception:
pass
logger.warning('pilot_id: %s', self.pilot_id)
logger.warning('hostname: %s', self.hostname)
# hint at resources for pilot
# don't pass them as raw, because that overrides condor
if 'resources' in config['options']:
for k in config['options']['resources']:
v = config['options']['resources'][k]
name = 'NUM_'+k.upper()
if k in ('cpu','gpu'):
name += 'S'
os.environ[name] = str(v)
self.resources = Resources(debug=self.debug)
self.start_time = time.time()
开发者ID:WIPACrepo,项目名称:iceprod,代码行数:35,代码来源:pilot.py
示例17: run
def run(self):
container = create_container(self.config)
install_plugins(container, self.config.get('plugins', {}))
install_interfaces(container, self.config.get('interfaces', {}))
for cls_name in self.args.get('--interface', ()):
cls = import_object(cls_name)
container.install(cls)
if self.args.get('--debug'):
from gevent.backdoor import BackdoorServer
backdoor = BackdoorServer(('127.0.0.1', 5005), locals={'container': container})
gevent.spawn(backdoor.serve_forever)
def handle_signal():
logger.info('caught SIGINT/SIGTERM, pid=%s', os.getpid())
container.stop()
container.join()
sys.exit(0)
gevent.signal(signal.SIGINT, handle_signal)
gevent.signal(signal.SIGTERM, handle_signal)
setproctitle('lymph-instance (identity: %s, endpoint: %s, config: %s)' % (
container.identity,
container.endpoint,
self.config.source,
))
container.start(register=not self.args.get('--isolated', False))
if self.args.get('--reload'):
set_source_change_callback(container.stop)
container.join()
开发者ID:adrpar,项目名称:lymph,代码行数:34,代码来源:service.py
示例18: run
def run(self):
setproctitle('satori: {0}'.format(self.name))
logging.info('%s starting', self.name)
signal(SIGTERM, self.handle_signal)
signal(SIGINT, self.handle_signal)
# let ssl register OpenSSL callbacks, so that they do not interfere with callbacks from OpenSSL.crypto
import ssl
# let pyOpenSSL register OpenSSL callbacks
import OpenSSL.SSL
import OpenSSL.crypto
# tell libpq not to register OpenSSL callbacks - hopefully no DB connection has been created yet
libpq = ctypes.cdll.LoadLibrary('libpq.so')
libpq.PQinitSSL(0)
try:
self.do_run()
except SystemExit:
logging.info('%s exited (SystemExit)', self.name)
except:
logging.exception('%s exited with error', self.name)
else:
logging.info('%s exited', self.name)
开发者ID:zielmicha,项目名称:satori,代码行数:28,代码来源:master_process.py
示例19: main
def main(self):
parser = argparse.ArgumentParser()
parser.add_argument('-c', metavar='CONFIG', default=DEFAULT_CONFIGFILE, help='Middleware config file')
parser.add_argument('-p', type=int, metavar='PORT', default=5500, help="WebSockets server port")
args = parser.parse_args()
configure_logging('/var/log/containerd.log', 'DEBUG')
setproctitle.setproctitle('containerd')
gevent.signal(signal.SIGTERM, self.die)
gevent.signal(signal.SIGQUIT, self.die)
self.config = args.c
self.init_datastore()
self.init_dispatcher()
self.init_mgmt()
self.init_nat()
self.init_ec2()
self.logger.info('Started')
# WebSockets server
kwargs = {}
s4 = WebSocketServer(('', args.p), ServerResource({
'/console': ConsoleConnection,
}, context=self), **kwargs)
s6 = WebSocketServer(('::', args.p), ServerResource({
'/console': ConsoleConnection,
}, context=self), **kwargs)
serv_threads = [gevent.spawn(s4.serve_forever), gevent.spawn(s6.serve_forever)]
gevent.joinall(serv_threads)
开发者ID:jatinder-kumar-calsoft,项目名称:middleware,代码行数:31,代码来源:main.py
示例20: start_worker_for_queue
def start_worker_for_queue(flow='simple_queue_processor', queue='zmon:queue:default', **execution_context):
"""
Starting execution point to the workflows
"""
known_flows = {'simple_queue_processor': flow_simple_queue_processor}
if flow not in known_flows:
logger.exception('Bad role: %s' % flow)
sys.exit(1)
logger.info('Starting worker with pid=%s, flow type: %s, queue: %s, execution_context: %s', os.getpid(), flow,
queue, execution_context)
setproctitle.setproctitle('zmon-worker {} {}'.format(flow, queue))
# start Flow Reactor here
FlowControlReactor.get_instance().start()
exit_code = 0
try:
known_flows[flow](queue=queue, **execution_context)
except (KeyboardInterrupt, SystemExit):
logger.warning('Caught user signal to stop consumer: finishing!')
except Exception:
logger.exception('Exception in start_worker(). Details: ')
exit_code = 2
finally:
FlowControlReactor.get_instance().stop()
sys.exit(exit_code)
开发者ID:drummerwolli,项目名称:zmon-worker,代码行数:31,代码来源:workflow.py
注:本文中的setproctitle.setproctitle函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论