监控你的 Swoole 程序文件变化并自动重启服务器 - 适用于开发php
Monitor for any changes in your swoole application and automatically restart the server - perfect for development node
SwooleFor 的定位就如同 PHP 版本的 nodemon, node-devpython
该项目使用 mix-phar 开发laravel
执行脚本命令:git
php swoolefor.phar --exec="php app.php arg..."
若是 disable_functions
禁用了 proc_open
方法,按以下方法执行:github
php -d disable_functions='' swoolefor.phar --exec="php app.php arg..."
启动成功:apache
_____ __ ______ / ___/ ______ ____ / /__ / ____/___ _____ \__ \ | /| / / __ \/ __ \/ / _ \/ /_ / __ \/ ___/ ___/ / |/ |/ / /_/ / /_/ / / __/ __/ / /_/ / / /____/|__/|__/\____/\____/_/\___/_/ \____/_/ Version: 1.1.1, Swoole: 4.4.0 [info] 2019-08-14 11:51:05.937 <920> [message] executor start, exec: [php /data/bin/mix-httpd start] [info] 2019-08-14 11:51:05.938 <920> [message] fork sub process, pid: 921 [info] 2019-08-14 11:51:05.939 <920> [message] monitor start [info] 2019-08-14 11:51:05.939 <920> [message] watch: /data [info] 2019-08-14 11:51:05.939 <920> [message] delay: 3s [info] 2019-08-14 11:51:05.939 <920> [message] ext: .php,.json
php swoolefor.phar --help
-e, --exec
Swoole application or other script start command-d, --daemon
Run in the background--watch
Watch code file directory--delay
File change delay processing (seconds)--ext
Monitor only changes to these extensions--signal
Send this signal to the process--exec
内部能够是任何命令,必须为绝对路径,必须为前台执行的常驻程序 (不然会致使不断fork进程)npm
php swoolefor.phar --exec="php app.php"
也可以使用短参数json
php swoolefor.phar -e "php app.php"
php swoolefor.phar --exec="node app.js"
php swoolefor.phar --exec="python app.py"
SwooleFor 自己能够在后台执行,这样能够脱离终端,增长 --daemon
便可服务器
php swoolefor.phar --exec="node app.js" --daemon
也可以使用短参数
php swoolefor.phar --exec="node app.js" -d
--watch
的默认值为 --exec
参数中脚本的当前目录,若是脚本是在 bin
目录中则会监控上一级的目录。
// 会自动监控 /data 目录 php swoolefor.phar --exec="php /data/bin/app.php"
指定监控其余目录
php swoolefor.phar --exec="php app.php" --watch=/tmp
当更新了不少文件时,咱们并不但愿程序一直频繁的重启,因此咱们须要设置一个延迟执行重启的时间,只有在达到设置的时间才执行重启操做。
--delay
默认为 3s
php swoolefor.phar --exec="php app.php" --delay=5
--ext
默认为 php,json
,当须要观察其余扩展名时可配置
php swoolefor.phar --exec="php app.php" --ext=php,json,ini
程序重启时终止进程是经过给进程发送信号完成的,当咱们须要指定信号时
--signal
默认为 15
php swoolefor.phar --exec="php app.php" --signal=1
经常使用的信号表
信号 | 值 |
---|---|
SIGTERM | 15 |
SIGKILL | 9 |
SIGHUP | 1 |
... | ... |
php swoolefor.phar -e "php /data/bin/mix-httpd start -c /data/applications/http/config/httpd.php"
php swoolefor.phar -e "php /data/bin/swoft http:start"
php swoolefor.phar -e "php /data/bin/easyswoole start"
php swoolefor.phar -e "php /data/bin/laravels start"
Apache License Version 2.0, http://www.apache.org/licenses/