public function handleStart(Control $control, Context $context)
    {
        if (! $context->pidfile instanceof Pidfile) {
            throw new LogicException('Pidfile is not defined');
        }

        // Activates the circular reference collector
        gc_enable();

        // Callback for handle when process is terminated
        $control->signal()->prependHandler(SIGTERM, function () use ($context) {
            $this->setAsDying();
            $context->pidfile->finalize();
        });
        $control->signal()->setHandler(SIGTSTP, SIG_IGN);
        $control->signal()->setHandler(SIGTTOU, SIG_IGN);
        $control->signal()->setHandler(SIGTTIN, SIG_IGN);
        $control->signal()->setHandler(SIGHUP, SIG_IGN);

        // Detach session
        $control->info()->detachSession();

        // Reset umask
        @umask($this->getOption('umask'));

        // Update work directory
        @chdir($this->getOption('work_dir'));

        // Close file descriptors
        fclose(STDIN);
        fclose(STDOUT);
        fclose(STDERR);

        // Define process owner
        if (null !== ($userId = $this->getOption('user_id'))) {
            $control->info()->setUserId($userId);
        }

        // Define process group
        if (null !== ($groupId = $this->getOption('group_id'))) {
            $control->info()->setGroupId($groupId);
        }

        // Create new file descriptors
        $context->stdin = fopen($this->getOption('stdin'), 'r');
        $context->stdout = fopen($this->getOption('stdout'), 'wb');
        $context->stderr = fopen($this->getOption('stderr'), 'wb');

        // Create pidfile
        $context->pidfile->initialize();
    }
public function handleStart(Control $control, Context $context)
    {
        if (! $context->pidfile instanceof Pidfile) {
            throw new LogicException('Pidfile is not defined');
        }

        // Activates the circular reference collector
        gc_enable();

        // Callback for handle when process is terminated
        $control->signal()->prependHandler(SIGTERM, function () use ($context) {
            $this->setAsDying();
            $context->pidfile->finalize();
        });
        $control->signal()->setHandler(SIGTSTP, SIG_IGN);
        $control->signal()->setHandler(SIGTTOU, SIG_IGN);
        $control->signal()->setHandler(SIGTTIN, SIG_IGN);
        $control->signal()->setHandler(SIGHUP, SIG_IGN);

        // Detach session
        $control->info()->detachSession();

        // Reset umask
        @umask($this->getOption('umask'));

        // Update work directory
        @chdir($this->getOption('work_dir'));

        // Close file descriptors
        fclose(STDIN);
        fclose(STDOUT);
        fclose(STDERR);

        // Define process owner
        if (null !== ($userId = $this->getOption('user_id'))) {
            $control->info()->setUserId($userId);
        }

        // Define process group
        if (null !== ($groupId = $this->getOption('group_id'))) {
            $control->info()->setGroupId($groupId);
        }

        // Create new file descriptors
        $context->stdin = fopen($this->getOption('stdin'), 'r');
        $context->stdout = fopen($this->getOption('stdout'), 'wb');
        $context->stderr = fopen($this->getOption('stderr'), 'wb');

        // Create pidfile
        $context->pidfile->initialize();
    }
public function handleStart ( Control $ control , Context $ context ) { if ( ! $ context -> pidfile instanceof Pidfile ) { throw new LogicException ( 'Pidfile is not defined' ) ; } // Activates the circular reference collector gc_enable ( ) ; // Callback for handle when process is terminated $ control -> signal ( ) -> prependHandler ( SIGTERM , function ( ) use ( $ context ) { $ this -> setAsDying ( ) ; $ context -> pidfile -> finalize ( ) ; } ) ; $ control -> signal ( ) -> setHandler ( SIGTSTP , SIG_IGN ) ; $ control -> signal ( ) -> setHandler ( SIGTTOU , SIG_IGN ) ; $ control -> signal ( ) -> setHandler ( SIGTTIN , SIG_IGN ) ; $ control -> signal ( ) -> setHandler ( SIGHUP , SIG_IGN ) ; // Detach session $ control -> info ( ) -> detachSession ( ) ; // Reset umask @ umask ( $ this -> getOption ( 'umask' ) ) ; // Update work directory @ chdir ( $ this -> getOption ( 'work_dir' ) ) ; // Close file descriptors fclose ( STDIN ) ; fclose ( STDOUT ) ; fclose ( STDERR ) ; // Define process owner if ( null !== ( $ userId = $ this -> getOption ( 'user_id' ) ) ) { $ control -> info ( ) -> setUserId ( $ userId ) ; } // Define process group if ( null !== ( $ groupId = $ this -> getOption ( 'group_id' ) ) ) { $ control -> info ( ) -> setGroupId ( $ groupId ) ; } // Create new file descriptors $ context -> stdin = fopen ( $ this -> getOption ( 'stdin' ) , 'r' ) ; $ context -> stdout = fopen ( $ this -> getOption ( 'stdout' ) , 'wb' ) ; $ context -> stderr = fopen ( $ this -> getOption ( 'stderr' ) , 'wb' ) ; // Create pidfile $ context -> pidfile -> initialize ( ) ; }
Default trigger for EVENT_START.

- Activates the circular reference collector
- Detach session
- Reset umask
- Update work directory
- Close file descriptors
- Define process owner, if any
- Define process group, if any
- Create new file descriptors
- Create pidfile
- Define pidfile cleanup

@param Control $control
@param Context $context
Default trigger for EVENT_START .