forked from kyour-cn/xoshe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sword
41 lines (32 loc) · 1.07 KB
/
sword
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env php
<?php
/**
* Easyswoole命令行
* 启动服务:./sword server start
* 常驻内存:./sword server start -d
* 停止服务:./sword server stop
*/
use EasySwoole\EasySwoole\Command\CommandRunner;
use EasySwoole\Command\Caller;
$file = __DIR__ . '/vendor/autoload.php';
if (file_exists($file)) {
require $file;
}else{
die("include composer autoload.php fail\n Please run: composer install\n");
}
$realCwd = substr(realpath($file),0,-strlen("/vendor/autoload.php"));
defined('IN_PHAR') or define('IN_PHAR', boolval(\Phar::running(false)));
defined('RUNNING_ROOT') or define('RUNNING_ROOT', $realCwd);
defined('EASYSWOOLE_ROOT') or define('EASYSWOOLE_ROOT', IN_PHAR ? \Phar::running() : $realCwd);
if(file_exists(EASYSWOOLE_ROOT.'/bootstrap.php')){
require_once EASYSWOOLE_ROOT.'/bootstrap.php';
}
$caller = new Caller();
$caller->setScript(current($argv));
$caller->setCommand(next($argv));
$caller->setParams($argv);
reset($argv);
$ret = CommandRunner::getInstance()->run($caller);
if($ret && !empty($ret->getMsg())){
echo $ret->getMsg()."\n";
}