创建一个新的 UnixPipes 实例
@param Process         $process
@param string|resource $input
@return self
192859
public static function create(Process $process, $input)
    {
        return new static($process->isTty(), $process->isPty(), $input, $process->isOutputDisabled());
    }
275254
protected function execute(InputInterface $input, OutputInterface $output)
    {
        /** @var \Symfony\Component\Console\Helper\ProcessHelper $process */
        $process = $this->getHelper('process');
        $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
        if (!is_dir(Platform::rootDir() . '/docker/fg')) {
            $process->mustRun($output, [
                'git',
                'clone',
                'https://github.com/brendangregg/FlameGraph.git',
              Platform::rootDir() . '/docker/fg'
            ]);
        }
        if (!is_dir(Platform::rootDir() . '/docker/xhpfg')) {
            $process->mustRun($output, [
              'git',
              'clone',
              'https://github.com/msonnabaum/xhprof-flamegraphs.git',
              Platform::rootDir() . '/docker/xhpfg'
            ]);
        }

        $stack = StacksFactory::getStack(Platform::webDir());
        switch ($stack->type()) {
            case Stacks\Drupal::TYPE:
                $this->stdOut->writeln("<comment>Patching Drupal for xhprof</comment>");
                $patchProcess = new Process(
                  'patch -p1 < ' . CLI_ROOT . '/resources/drupal-enable-profiling.patch',
                  Platform::webDir()
                );
                break;
            case Stacks\WordPress::TYPE:
                $this->stdOut->writeln("<comment>Patching WordPress for xhprof</comment>");
                $patchProcess = new Process(
                  'patch -p0 < ' . CLI_ROOT . '/resources/wordpress-enable-profiling.patch',
                  Platform::webDir()
                );
                break;
            default:
                throw new \Exception('Stack type not supported yet.');
        }
        $patchProcess->mustRun();
    }
71044
public function addProcess(Process $process): void
    {
        $this->container->make(Server::class)->addProcess($process);
    }
807666
public function setProcess(ProcessInterface $process)
    {
        $this->process = $process;
        $this->setClient($process->getClient());

        return $this;
    }
377657
public function doRun(InputInterface $input, OutputInterface $output)
    {
        $this->setOutput($output);

        $this->resetCodeBuffer();

        $this->setAutoExit(false);
        $this->setCatchExceptions(false);

        $this->readline->readHistory();

        $this->output->writeln($this->getHeader());
        $this->writeVersionInfo();
        $this->writeStartupMessage();

        try {
            $this->beforeRun();
            $this->loop->run($this);
            $this->afterRun();
        } catch (ThrowUpException $e) {
            throw $e->getPrevious();
        } catch (BreakException $e) {
            // The ProcessForker throws a BreakException to finish the main thread.
            return;
        }
    }
576476
public function setProcess(\Minibus\Model\Entity\Process $process = null)
    {
        $this->process = $process;
        
        return $this;
    }
1024386
public function process(array $input)
    {
        try
        {
            $success = $this->v->validate($input);
        }
        catch(ValidationException $e)
        {
            $this->setErrorsAndThrowException();
        }
        if( ! $success)
        {
            $this->setErrorsAndThrowException();
        }

        Event::fire("form.processing", array($input));
        return $this->callRepository($input);
    }
240465
protected function start()
    {
        $this->processes[] = $this->createProcess()->handleOutputUsing(function ($type, $line) {
            call_user_func($this->output, $type, $line);
        });

        return $this;
    }
876416
public static function create(string $name): Process
    {
        if (isset(self::$processes[$name])) {
            return self::$processes[$name];
        }

        list($name, $boot, $pipe, $inout, $co) = self::getProcessMaping($name);
        $swooleProcess = new SwooleProcess(function (SwooleProcess $swooleProcess) use ($name, $co, $boot) {
            $process = new Process($swooleProcess);
            if ($co) {
                self::runProcessByCo($name, $process, $boot);

                return;
            }
            self::runProcessByDefault($name, $process, $boot);
        }, $inout, $pipe);
        $process = new Process($swooleProcess);
        self::$processes[$name] = $process;

        return $process;
    }
1256566
private void startProcess() throws IOException {
    LOG.info("Building process");
    ProcessBuilder processBuilder = new ProcessBuilder(command);
    processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT);
    processBuilder.redirectOutput(ProcessBuilder.Redirect.INHERIT);
 
    LOG.info("Starting process");
    process = processBuilder.start();
    LOG.info("Process started");
  }
1050285
public void addProcess(Process process) {
        ResourceTypePackageRegistry rtps = getResourceTypePackages();
        ProcessPackage rtp = ProcessPackage.getOrCreate(rtps);
        rtp.add(process);
    }
660840
public static function create($name, $args = [], $redirectStdinStdout = null, $pipeType = null): \Swoole\Process
    {
        $processOption = ProcessParser::getInstance()->getProcess($name);
        if(null === $processOption)
        {
            return null;
        }
        if($processOption['Process']->unique && static::isRunning($name))
        {
            throw new ProcessAlreadyRunException(sprintf('Process %s already run', $name));
        }
        if(null === $redirectStdinStdout)
        {
            $redirectStdinStdout = $processOption['Process']->redirectStdinStdout;
        }
        if(null === $pipeType)
        {
            $pipeType = $processOption['Process']->pipeType;
        }
        $processInstance = BeanFactory::newInstance($processOption['className'], $args);
        $process = new \Swoole\Process(function(\Swoole\Process $swooleProcess) use($processInstance, $name, $processOption){
            // 设置进程名称
            Imi::setProcessName('process', [
                'processName'   =>  $name,
            ]);
            // 随机数播种
            mt_srand();
            if($processOption['Process']->unique)
            {
                if(!static::lockProcess($name))
                {
                    throw new \RuntimeException('lock process lock file error');
                }
            }
            // 加载服务器注解
            \Imi\Bean\Annotation::getInstance()->init(\Imi\Main\Helper::getAppMains());
            App::initWorker();
            // 进程开始事件
            Event::trigger('IMI.PROCESS.BEGIN', [
                'name'      => $name,
                'process'   => $swooleProcess,
            ]);
            // 执行任务
            call_user_func([$processInstance, 'run'], $swooleProcess);
            swoole_event_wait();
            if($processOption['Process']->unique)
            {
                static::unlockProcess($name);
            }
            // 进程结束事件
            Event::trigger('IMI.PROCESS.END', [
                'name'      => $name,
                'process'   => $swooleProcess,
            ]);
        }, $redirectStdinStdout, $pipeType);
        return $process;
    }
999834
public function fork(ProcessContract $process)
    {
        $this->swooleServer->addProcess($process->getSwooleProcess());

        $process->bind($this);
    }
905844
public function start($process)
    {
        $this->jsonFormatHandler();
        if (!is_file(BIN_DIR.'/exec/consul')) {
            secho('[CONSUL]', 'consul没有安装,请下载最新的consul安装至bin/exec目录,或者在config/consul.php中取消使能');
            get_instance()->server->shutdown();
            exit();
        }

        $this->exec(BIN_DIR.'/exec/consul', ['agent', '-ui', '-config-dir', BIN_DIR.'/exec/consul.d']);
    }
738453
protected function runProcess(Process $process)
    {
        $output = $this->output;

        $process->run(
            function ($type, $buffer) use ($output) {
                $type;
                $output->write($buffer);
            }
        );

        return $process->isSuccessful();
    }
70170
function pipe(commands, input) {
  if (!commands) {
    return input;
  }
  return commands.reduce(function(input, cmd) {
    return npmRun.sync(cmd, {
      input: input
    });
  }, input);
}
1127574
public final static String process(final String input, final Configuration configuration)
    {
        try
        {
            return process(new StringReader(input), configuration);
        }
        catch (final IOException e)
        {
            // This _can never_ happen
            return null;
        }
    }