Post-daemonize initialization
3225
protected function initializeDaemon() {
        declare (ticks = 100);

        // Install signal handlers
        pcntl_signal(SIGHUP, [$this, 'handleSignal']);
        pcntl_signal(SIGINT, [$this, 'handleSignal']);
        pcntl_signal(SIGTERM, [$this, 'handleSignal']);
        pcntl_signal(SIGCHLD, [$this, 'handleSignal']);
        pcntl_signal(SIGUSR1, [$this, 'handleSignal']);
        pcntl_signal(SIGUSR2, [$this, 'handleSignal']);
    }
795133
def init(runlevel):
    '''
    
    '''
    cmd = ['init', '{0}'.format(runlevel)]
    ret = __salt__['cmd.run'](cmd, python_shell=False)
    return ret
1371182
def postprocessor(accepts, flag=None):
    """"""
    def decorator(f):
        postprocessors.append((accepts, flag, f))
        return f
    return decorator
409424
@PostConstruct
    public synchronized void initialize() {
        final FwCoreDirection direction = assistCoreDirection();
        final ConcurrentAsyncExecutorProvider provider = direction.assistConcurrentAsyncExecutorProvider();
        defaultConcurrentAsyncOption = provider != null ? provider.provideDefaultOption() : null;
        if (defaultConcurrentAsyncOption == null) {
            defaultConcurrentAsyncOption = new ConcurrentAsyncOption();
        }
        primaryExecutorService = createDefaultPrimaryExecutorService(provider);
        secondaryExecutorService = createDefaultSecondaryExecutorService(provider);
        tertiaryExecutorService = createDefaultSecondaryExecutorService(provider);
        showBootLogging();
    }
1241294
def main():
    
    (options, _) = _parse_args()

    if options.change_password:
        c.keyring_set_password(c["username"])
        sys.exit(0)

    if options.select:
        courses = client.get_courses()
        c.selection_dialog(courses)
        c.save()
        sys.exit(0)

    if options.stop:
        os.system("kill -2 `cat ~/.studdp/studdp.pid`")
        sys.exit(0)

    task = _MainLoop(options.daemonize, options.update_courses)

    if options.daemonize:
        log.info("daemonizing...")
        with daemon.DaemonContext(working_directory=".", pidfile=PIDLockFile(PID_FILE)):
            # we have to create a new logger in the daemon context
            handler = logging.FileHandler(LOG_PATH)
            handler.setFormatter('%(asctime)s [%(levelname)s] %(name)s: %(message)s')
            log.addHandler(handler)
            task()
    else:
        task()
445866
def _initRepository(self):
        
        if self._isRepositoryReady():
            return defer.succeed(None)
        log.msg('hgpoller: initializing working dir from %s' % self.repourl)
        d = utils.getProcessOutputAndValue(self.hgbin,
                                           ['init', self._absWorkdir()],
                                           env=os.environ)
        d.addCallback(self._convertNonZeroToFailure)
        d.addErrback(self._stopOnFailure)
        d.addCallback(lambda _: log.msg(
            "hgpoller: finished initializing working dir %r" % self.workdir))
        return d
51511
def _daemonize(self):
        
        try:
            pid = os.fork()
            if pid > 0:
                sys.exit(0)
        except OSError, e:
            sys.stderr.write("fork #1 failed: %d (%s)\n" %
                             (e.errno, e.strerror))
            sys.exit(1)

        os.setsid()
        os.chdir("/")
        os.umask(0)

        try:
            pid = os.fork()
            if pid > 0:
                sys.exit(0)
        except OSError, e:
            sys.stderr.write("fork #2 failed: %d (%s)\n" %
                             (e.errno, e.strerror))
            sys.exit(1)

        sys.stdout.flush()
        sys.stderr.flush()
        if self.stdin:
            si = file(self.stdin, 'r')
            os.dup2(si.fileno(), sys.stdin.fileno())
        if self.stdout:
            so = file(self.stdout, 'a+')
            os.dup2(so.fileno(), sys.stdout.fileno())
        if self.stderr:
            se = file(self.stderr, 'a+', 0)
            os.dup2(se.fileno(), sys.stderr.fileno())
        atexit.register(self.delpid)
        pid = str(os.getpid())
        file(self.pidfile, 'w+').write("%s\n" % pid)
88603
private void ensureInitialized() {
    if (!mInitialized) {
     lock.lock();
      try {
        if (!mInitialized) {
          mInternalPath = Environment.getDataDirectory();
          mExternalPath = Environment.getExternalStorageDirectory();
          updateStats();
          mInitialized = true;
        }
      } finally {
        lock.unlock();
      }
    }
  }
744073
private void init() {
        assertUnlocked();
        
        lock.lock();
        try {
            httpSender.init(cfg);

            LOG.info(
                "Starting with "
                    + DEFAULT_REQ_PROC_COUNT + " request processors");

            procThreads = new RequestProcessor[DEFAULT_REQ_PROC_COUNT];

            for (int i = 0; i < procThreads.length; i++) {
                procThreads[i] = new RequestProcessor(i);
                procThreads[i].start();
            }

        } finally {
            lock.unlock();
        }
    }
1008672
@Override
    public void postInitModule() throws ModuleInitializationException {
        ConnectionPoolManager mgr =
                (ConnectionPoolManager) getServer()
                        .getModule("org.fcrepo.server.storage.ConnectionPoolManager");
        if (mgr == null) {
            throw new ModuleInitializationException("ConnectionPoolManager module not loaded.",
                                                    getRole());
        }
        try {
            m_pidGenerator = new DBPIDGenerator(mgr.getPool(), m_oldPidGenDir);
        } catch (Exception e) {
            String msg = "Can't get default connection pool";
            logger.error(msg, e);
            throw new ModuleInitializationException(msg, getRole());
        }
    }
149190
async function init () {
  try {
    await sequelize.sync()
  } catch (err) {
    console.log(err)
    process.exit(-1)
  }
}
1078275
public function init() {

        $args = $this->console->arguments;

        $args->parse();

        if ( $args->defined('hardstart') ) {

            $this->hardstart();

        }

        if ( $args->defined('daemon') ) {

            $this->daemonize();

        } else if ( $args->defined('foreground') ) {

            if ( $args->defined('verbose') ) {
                $this->logger->pushHandler(new LogHandler());
            }

            $this->start();

        } else {

            $this->console->pad()->green()->usage();
            $this->end(0);

        }

    }
413763
function setupProcess(aLogger, aDaemonize, aLogFile) {
  aLogger.log('Setting up process. Run as a daemon:', aDaemonize, 'Logfile:', aLogFile);

  // Since we might need to open some files, and that's an asynchronous operation,
  // we will return a promise here that will never resolve on the parent (process will die instead)
  // and will resolve on the child
  return new Promise((resolve) => {
    if (!aDaemonize) {
      return resolve();
    }

    if (!aLogFile) {
      return resolve({ stdout: process.stdout, stderr: process.stderr });
    }

    const fs = require('fs');
    const outputStream = fs.createWriteStream(aLogFile);
    outputStream.on('open', () => resolve({
      stdout: outputStream,
      stderr: outputStream,
      cwd: process.cwd(),
    }));
    return null;
  }).then((daemonOpts) => {
    // No need to continue, let's make ourselves a daemon.
    if (daemonOpts) {
      require('daemon')(daemonOpts);
    }

    const signals = [
      'SIGINT', 'SIGQUIT', 'SIGILL', 'SIGTRAP', 'SIGABRT', 'SIGBUS',
      'SIGFPE', 'SIGUSR1', 'SIGSEGV', 'SIGALRM', 'SIGTERM',
    ];

    process.on(
      'uncaughtException', err => aLogger.error('Got an uncaught exception:', err, err.stack));

    process.on('unhandledRejection', (aReason) => {
      aLogger.error('Unhandled Rejection:', aReason);
      if (aReason.message && aReason.message.startsWith('FATAL:')) {
        aLogger.error('Exiting because of a fatal error:', aReason);
        process.exit(1);
      }
    });

    process.on('SIGHUP', () => {
      if (sighup.handler && sighup.handler instanceof Function) {
        aLogger.log('Got SIGHUP. Reloading config!');
        sighup.handler();
      } else {
        aLogger.log('Got SIGHUP. Ignoring!');
      }
    });

    // Sometime we get a SIGPIPE for some unknown reason. Just log and ignore it.
    process.on('SIGPIPE', () => {
      aLogger.log('Got SIGPIPE. Ignoring');
    });

    process.on('exit', () => {
      aLogger.log('Node process exiting!');
    });

    const SIGNAL_TEMPLATE_FN = (aSignal) => {
      aLogger.log(aSignal, 'captured! Exiting now.');
      process.exit(1);
    };

    signals.forEach((aSignalName) => {
      aLogger.trace('Setting handler', aSignalName);
      process.on(aSignalName, SIGNAL_TEMPLATE_FN.bind(undefined, aSignalName));
    });
  });

}
684163
def listen_init(self):
        """"""
        self.dispatcher = ObjectDispatch(self)
        self.factory = MsgPackProtocolFactory(self.dispatcher)
        self.server = UnixServer(self.loop, self.factory, self.path)
        self.server.start()
625322
protected function initialize()
    {
        if ($this->initialized === true) {
            return;
        }
        $this->initialized = true;
        $this->buildFullConfiguration();
        $this->applyPostprocessing();
    }
169264
private void initializeNonPersistent() {
        if (TraceComponent.isAnyTracingEnabled()
            && tc.isEntryEnabled())
            SibTr.entry(tc, "initializeNonPersistent");

        // Initialise MatchSpace
        _messageProcessorMatching = new MessageProcessorMatching(this);

        // Create the access checker for discriminator authorization
        _topicAuthorization = new TopicAuthorization(this);

        _searchResultsPool.setTopicAuthorization(_topicAuthorization);

        // set the authorizer into the general MP Access Checker
        _accessChecker.setTopicAuthorization(_topicAuthorization);

        // Create the administrator
        // Needs to be done before D3 initialise as it is used by D3.
        // Needs to be done after a DestinationManager has been recovered/setup
        _administrator = new AdministratorImpl(this);

        // Venu Liberty change
        //making all TRM related objects to NULL
        // These objects all togehter can have been removed, however as the decission had been take to 
        // keep ME-ME communication, retaining them so that ME-ME related artifacts would get built
        /*
         * // 175358 Locate TRM class using JsConstants
         * TrmMeMain trm = (TrmMeMain) _engine
         * .getEngineComponent(JsConstants.SIB_CLASS_TO_ENGINE);
         * 
         * if (trm == null) {
         * if (TraceComponent.isAnyTracingEnabled()
         * && tc.isEntryEnabled())
         * SibTr.exit(tc, "initializeNonPersistent", "WsRuntimeException");
         * 
         * // Log error to console
         * SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0001", new Object[] {
         * "com.ibm.ws.sib.processor.impl.MessageProcessor",
         * "1:2117:1.445" });
         * 
         * throw new SIErrorException(nls.getFormattedMessage(
         * "INTERNAL_MESSAGING_ERROR_CWSIP0001", new Object[] {
         * "com.ibm.ws.sib.processor.impl.MessageProcessor",
         * "1:2122:1.445" }, null));
         * }
         * 
         * _destinationLocationManager = trm.getDestinationLocationManager();
         * _linkManager = trm.getLinkManager();
         * _mqLinkManager = trm.getMQLinkManager();
         * RoutingManager routingManager = trm.getRoutingManager();
         * CommsErrorListener errorListener = trm.getCommsErrorListener();
         */
        _destinationLocationManager = null;
        _linkManager = null;
        _mqLinkManager = null;
        RoutingManager routingManager = null;
        CommsErrorListener errorListener = null;

        _mpio.init(errorListener, routingManager);

        try {
            // Venu Liberty change:
            //commenting below line to avoid PMI
            //_rmImpl = SIBPmiRm.getInstance();
        } catch (Exception e) {
            FFDCFilter
                            .processException(
                                              e,
                                              "com.ibm.ws.sib.processor.impl.MessageProcessor.initializeNonPersistent",
                                              "1:2142:1.445", this);

            SIErrorException e2 = new SIErrorException(nls.getFormattedMessage(
                                                                               "INTERNAL_MESSAGING_ERROR_CWSIP0002",
                                                                               new Object[] {
                                                                                             "com.ibm.ws.sib.processor.impl.MessageProcessor",
                                                                                             "1:2150:1.445", e }, null), e);

            SibTr.exception(tc, e2);

            if (TraceComponent.isAnyTracingEnabled()
                && tc.isEntryEnabled())
                SibTr.exit(tc, "initializeNonPersistent", e2);

            throw e2;
        }

        if (TraceComponent.isAnyTracingEnabled()
            && tc.isEntryEnabled())
            SibTr.exit(tc, "initializeNonPersistent");
    }
1073487
public function daemonize() {

        // fork script
        $pid = $this->fork();

        // detach from current terminal (if any)
        $this->detach();

        // update pid reference (we have a new daemon)
        $this->pid = $pid;

        // start process daemon
        $this->start();

    }