예제 #1
0
def exec_worker(worker_id=None):
    """
    used to create a worker for an existing zenoss daemon. Removes the
    "workers" and "daemon" sys args and replace the current process by
    executing sys args
    """

    #Here we are just registering parents death signal as this childs terminal signal as well.
    #When the parent dies (for whatever reason), the child will get SIGTERM.
    libc = ctypes.CDLL(find_library('c'))
    PR_SET_PDEATHSIG = 1
    libc.prctl(PR_SET_PDEATHSIG, signal.SIGTERM)

    argv = [sys.executable]
    # Remove unwanted parameters from worker processes
    argv.extend(remove_args(sys.argv[:], ['-D','--daemon','-c','--cycle'], ['--workerid']))
    if worker_id is not None:
        argv.append('--workerid=%d'%worker_id)
    # Tell the worker process to log to the log file and not just to console
    argv.append('--duallog')
    try:
        log.info("starting worker process")
        os.execvp(argv[0], argv)
    except Exception:
        log.exception("Failed to start process")
예제 #2
0
def exec_worker(worker_id=None):
    """
    used to create a worker for an existing zenoss daemon. Removes the
    "workers" and "daemon" sys args and replace the current process by
    executing sys args
    """

    #Here we are just registering parents death signal as this childs terminal signal as well.
    #When the parent dies (for whatever reason), the child will get SIGTERM.
    libc = ctypes.CDLL(find_library('c'))
    PR_SET_PDEATHSIG = 1
    libc.prctl(PR_SET_PDEATHSIG, signal.SIGTERM)

    argv = [sys.executable]
    # Remove unwanted parameters from worker processes
    argv.extend(remove_args(sys.argv[:], ['-D','--daemon','-c','--cycle'], ['--workerid']))
    if worker_id is not None:
        argv.append('--workerid=%d'%worker_id)
    # Tell the worker process to log to the log file and not just to console
    argv.append('--duallog')
    try:
        log.info("starting worker process")
        os.execvp(argv[0], argv)
    except:
        log.exception("Failed to start process")
예제 #3
0
def exec_worker():
    """
    used to create a worker for an existing zenoss daemon. Removes the
    "workers" and "daemon" sys args and replace the current process by
    executing sys args
    """
    argv = [sys.executable]
    # Remove unwanted parameters from worker processes
    argv.extend(remove_args(sys.argv[:], ['-D','--daemon'], ['--workers']))
    # Tell the worker process to log to the log file and not just to console
    argv.append('--duallog')
    try:
        os.execvp(argv[0], argv)
    except:
        log.exception("Failed to start process")
예제 #4
0
def exec_worker():
    """
    used to create a worker for an existing zenoss daemon. Removes the
    "workers" and "daemon" sys args and replace the current process by
    executing sys args
    """
    argv = [sys.executable]
    # Remove unwanted parameters from worker processes
    argv.extend(remove_args(sys.argv[:], ['-D', '--daemon'], ['--workers']))
    # Tell the worker process to log to the log file and not just to console
    argv.append('--duallog')
    try:
        os.execvp(argv[0], argv)
    except:
        log.exception("Failed to start process")
예제 #5
0
def exec_worker(offset, chunk):
    """
    Used to create a worker for zenmapper daemon. Removes the
    "cycle", "workers" and "daemon" sys args and replace the current process by
    executing sys args
    """
    argv = [sys.executable]
    # Remove unwanted parameters from worker processes
    argv.extend(remove_args(sys.argv[:],
        ['-D','--daemon', '-c', '--cycle'], ['--workers']))
    # Tell the worker process to log to the log file and not just to console
    argv.append('--duallog')
    argv.append('--worker')
    argv.append('--offset=%i' % offset)
    argv.append('--chunk=%i' % chunk)
    try:
        os.execvp(argv[0], argv)
    except:
        LOG.exception("failed to start worker process")
예제 #6
0
def exec_worker(offset, chunk):
    """
    Used to create a worker for zenmapper daemon. Removes the
    "cycle", "workers" and "daemon" sys args and replace the current process by
    executing sys args
    """
    argv = [sys.executable]
    # Remove unwanted parameters from worker processes
    argv.extend(remove_args(sys.argv[:],
        ['-D','--daemon', '-c', '--cycle'], ['--workers']))
    # Tell the worker process to log to the log file and not just to console
    argv.append('--duallog')
    argv.append('--worker')
    argv.append('--offset=%i' % offset)
    argv.append('--chunk=%i' % chunk)
    try:
        os.execvp(argv[0], argv)
    except:
        log.exception("Failed to start process")