Code Monkey home page Code Monkey logo

go-watch's Introduction

监控你的程序文件变化并自动重启服务

docker 编译

docker create -it -e GOPROXY=https://goproxy.io --name myGolang -v /opt:/root/src -w /root/src golang bash
docker start myGolang
docker exec -it myGolang bash
git clone https://github.com/buexplain/go-watch.git
cd go-watch
CGO_ENABLED=0 go build -o gowatch main.go
  1. 编译时候必须设置环境变量GOPROXY=https://goproxy.io,避免下载golang的包被墙。
  2. 如果需要在docker中使用这个工具,则编译的时候必须设置CGO_ENABLED=0,否则编译后的包,不能在docker中使用。

使用说明

chmod u+x gowatch
./gowatch run -h
Usage:
   run [flags]

Flags:
      --args strings        启动命令所需参数
      --autoRestart         是否自动重启子进程,子进程非守护类型不建议自动重启
      --cmd string          启动命令
      --delay uint          命令延迟执行秒数 (default 2)
      --files strings       监视的文件
      --folder strings      监视的文件夹
  -h, --help                help for run
      --pattern string      监视文件变化的方式 poll 或 notify (default "poll")
      --preCmd string       预处理命令,启动命令执行前执行的命令
      --preCmdIgnoreError   是否忽略预处理命令的错误
      --preCmdTimeout int   预处理命令执行超时秒数 (default 10)
      --signal int          子进程关闭信号 (default 15)
      --timeout int         等待子进程关闭超时秒数 (default 5)
  1. 参数输入格式,请参阅cobra库。
  2. 如果操作系统不支持监视相关事件,或者是虚拟机与宿主机共享文件夹的情况下,那么只能使用 --pattern=poll 方式轮询监视文件。
  3. 参数--preCmd的值只支持用/bin/bash执行。
  4. 有时候预处理命令的结束code不是1,此时需要传递参数--preCmdIgnoreError=true

使用示例

以PHP类项目hyperf为例子,使用方式如下:

./gowatch run\
 --preCmd "php /hyperf-skeleton/bin/hyperf.php di:init-proxy"\
 --preCmdIgnoreError=true\
 --cmd "php"\
 --args "/hyperf-skeleton/bin/hyperf.php, start"\
 --files "/hyperf-skeleton/test/.env"\
 --folder "/hyperf-skeleton/app/, /hyperf-skeleton/config/"\
 --autoRestart=true

License

Apache-2.0

go-watch's People

Contributors

buexplain avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

go-watch's Issues

ERROR Swoole short name have to disable before start server, please set swoole.use_shortname = 'Off' into your php.ini.

`swoole

Swoole => enabled
Author => Swoole Team [email protected]
Version => 4.4.3
Built => Aug 7 2019 10:50:26
coroutine => enabled
kqueue => enabled
rwlock => enabled
http2 => enabled
pcre => enabled
zlib => enabled
async_redis => enabled

Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.enable_library => On => On
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => Off => Off
swoole.unixsock_buffer_size => 262144 => 262144`

请问为什么还是会报错,需要设置swoole.use_shortname = Off

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.