本文整理汇总了Python中setproctitle.setproctitle函数的典型用法代码示例。如果您正苦于以下问题:Python setproctitle函数的具体用法?Python setproctitle怎么用?Python setproctitle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setproctitle函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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()
示例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()
示例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'
)
示例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
示例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)
示例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()
示例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))
示例9: _set_process_title
def _set_process_title():
try:
import setproctitle
except ImportError:
pass
else:
setproctitle.setproctitle("kupfer")
示例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()
示例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
示例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'
)
示例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
示例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")
示例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()