Esempio n. 1
0
<?php

//作为一个守护进程?   可以查看启动哪些server
use Swoole\ArgParser;
define('START_BASE_PATH', dirname(dirname(__DIR__)));
define('SuperProcessName', 'Swoole-Controller');
define('uniSockPath', "/tmp/" . SuperProcessName . ".sock");
require START_BASE_PATH . '/library/Swoole/ArgParser.php';
$cmds = ['start', 'stop', 'reload', 'restart', 'shutdown', 'status', 'list', 'startall'];
//php swoole.php testserver start
$parser = new ArgParser();
$parser->add('name', ['help' => 'The name of config filename']);
$parser->add('cmd', ['help' => 'The cmd of start|stop|restart', 'default' => '']);
$usage = $parser->usage(printInfo());
// Try to parse the arguments
if (!($args = $parser->parse())) {
    print $parser->help();
    exit;
}
$name = $args['name'];
$cmd = $args['cmd'];
//cmd name
$cmd = empty($cmd) ? $name : $cmd;
$RunningServer = [];
//需要cmd 和 name  name 支持 all 和 具体的serverName
if (!$cmd || !$name && ($cmd != 'status' && $cmd != 'shutdown' && $cmd != 'list' && $cmd != 'startall') || !in_array($cmd, $cmds)) {
    echo $usage;
    exit(1);
}
//servername 合法性校验
if ($cmd != 'status' && $cmd != 'shutdown' && $cmd != 'startall' && $cmd != 'list') {
Esempio n. 2
0
#!/usr/bin/env php
<?php 
/**
 * start.php.
 * Author: yeweijian
 * E-mail: yeweijian@hoolai.com
 * Date: 2016/1/15
 * Time: 15:56
 */
use Swoole\ArgParser;
use Swoole\Exception;
use Swoole\Protocol\ProtocolAbstract;
use Swoole\Server\ServerAbstract;
require dirname(__DIR__) . '/sys_config.php';
$parser = new ArgParser();
$parser->add('cmd', array('help' => 'The cmd of start|stop|restart'));
$parser->add('name', array('help' => 'The name of config filename'));
// Try to parse the arguments
if (!($args = $parser->parse())) {
    print $parser->help();
    exit;
}
//读取配置
$cmd = $args['cmd'];
//cmd name
$name = $args['name'];
//需要cmd 和 name  name 支持 all 和 具体的serverName
if (!$cmd || !$name) {
    echo "please input cmd and server name: start all,start testserv ";
    exit;
}