Compare commits
21 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
585f6e4389 | ||
|
600275f4a4 | ||
|
a31bf71c1c | ||
|
da54305188 | ||
|
9e651d3023 | ||
|
605914d1e1 | ||
|
86cf40564b | ||
|
819297118c | ||
|
a76d4cfe6c | ||
|
14ba79c2b3 | ||
|
c5f0649ab5 | ||
|
7c6f8f910b | ||
|
d07616bde9 | ||
|
4f81692954 | ||
|
588af5143f | ||
|
2d8924b7fe | ||
|
08fb7aabf8 | ||
|
9f0a51ce0e | ||
|
8a3a2d570b | ||
|
e5405f4fa9 | ||
|
9d9cce0f31 |
45
.github/workflows/go.yml
vendored
Normal file
45
.github/workflows/go.yml
vendored
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
name: Go
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
build:
|
||||||
|
name: Build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- name: Set up Go 1.13
|
||||||
|
uses: actions/setup-go@v1
|
||||||
|
with:
|
||||||
|
go-version: 1.13
|
||||||
|
id: go
|
||||||
|
|
||||||
|
- name: Check out code into the Go module directory
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Get dependencies
|
||||||
|
run: |
|
||||||
|
export GO111MODULE=on
|
||||||
|
go env -w GOPROXY=https://goproxy.io,direct
|
||||||
|
go get
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: go build
|
||||||
|
|
||||||
|
- name: Use
|
||||||
|
run: |
|
||||||
|
export PATH=/home/runner/work/fileboy/fileboy:$PATH
|
||||||
|
fileboy version
|
||||||
|
fileboy help
|
||||||
|
fileboy init
|
||||||
|
cat filegirl.yaml
|
||||||
|
fileboy exec
|
||||||
|
fileboy daemon
|
||||||
|
ls -al .fileboy.pid
|
||||||
|
ps aux | grep fileboy
|
||||||
|
fileboy stop
|
@@ -20,7 +20,7 @@ script:
|
|||||||
- fileboy init
|
- fileboy init
|
||||||
- cat filegirl.yaml
|
- cat filegirl.yaml
|
||||||
- fileboy exec
|
- fileboy exec
|
||||||
- fileboy deamon
|
- fileboy daemon
|
||||||
- ls -al .fileboy.pid
|
- ls -al .fileboy.pid
|
||||||
- ps aux | grep fileboy
|
- ps aux | grep fileboy
|
||||||
- fileboy stop
|
- fileboy stop
|
||||||
|
20
CHANGELOG.md
20
CHANGELOG.md
@@ -1,3 +1,23 @@
|
|||||||
|
### Release v1.16
|
||||||
|
|
||||||
|
2020.12.03
|
||||||
|
|
||||||
|
- 修改 进程退出清理日志级别
|
||||||
|
- 增加 MIT Copyright
|
||||||
|
|
||||||
|
2020.08.23
|
||||||
|
|
||||||
|
- 优化 文件扫描性能
|
||||||
|
|
||||||
|
2020.07.19
|
||||||
|
|
||||||
|
- 增加 pid 文件处理
|
||||||
|
- 增加 信息处理
|
||||||
|
|
||||||
|
2020.03.16
|
||||||
|
|
||||||
|
- typo deamon->daemon
|
||||||
|
|
||||||
### Release v1.15
|
### Release v1.15
|
||||||
|
|
||||||
2020.03.08
|
2020.03.08
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
## 项目说明
|
## 项目说明
|
||||||
|
|
||||||
[](https://travis-ci.org/dengsgo/fileboy) [](https://goreportcard.com/report/github.com/dengsgo/fileboy)
|
 [](https://travis-ci.org/dengsgo/fileboy) [](https://goreportcard.com/report/github.com/dengsgo/fileboy)
|
||||||
|
|
||||||
[简体中文](README.md) | [ENGLISH](README_EN.md)
|
[简体中文](README.md) | [ENGLISH](README_EN.md)
|
||||||
|
|
||||||
fileboy,文件变更监听通知系统,使用 Go 编写。
|
fileboy,文件变更监听通知工具,使用 Go 编写。
|
||||||
适用于 Hot Reload (典型的如开发go项目,无需每次手动执行 go build;又比如前端 node 打包) 或者 系统监控的场景。
|
适用于 Hot Reload (典型的如开发go项目,无需每次手动执行 go build;又比如前端 node 打包) 或者 系统监控的场景。
|
||||||
|
|
||||||
## 特性
|
## 特性
|
||||||
@@ -140,7 +140,7 @@ notifier:
|
|||||||
# 请求超时 15 秒
|
# 请求超时 15 秒
|
||||||
# POST 格式:
|
# POST 格式:
|
||||||
# Content-Type: application/json;charset=UTF-8
|
# Content-Type: application/json;charset=UTF-8
|
||||||
# User-Agent: FileBoy Net Notifier v1.15
|
# User-Agent: FileBoy Net Notifier v1.16
|
||||||
# Body: {"project_folder":"/project/path","file":"main.go","changed":1576567861913824940,"ext":".go","event":"write"}
|
# Body: {"project_folder":"/project/path","file":"main.go","changed":1576567861913824940,"ext":".go","event":"write"}
|
||||||
# 例: http://example.com/notifier/fileboy-listener
|
# 例: http://example.com/notifier/fileboy-listener
|
||||||
# 不启用通知,请留空 ""
|
# 不启用通知,请留空 ""
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
[简体中文](README.md) | [ENGLISH](README_EN.md)
|
[简体中文](README.md) | [ENGLISH](README_EN.md)
|
||||||
|
|
||||||
Fileboy, File Change Monitoring Notification System, written with Go.
|
Fileboy, File Change Monitoring Notification Tool Software, written with Go.
|
||||||
For Hot Reload scenarios (typically for developing go projects without having to perform go build manually every time; for example, front-end node packaging) or system monitoring.
|
For Hot Reload scenarios (typically for developing go projects without having to perform go build manually every time; for example, front-end node packaging) or system monitoring.
|
||||||
|
|
||||||
## FEATURES
|
## FEATURES
|
||||||
@@ -134,7 +134,7 @@ notifier:
|
|||||||
# timeout 15 second
|
# timeout 15 second
|
||||||
# POST :
|
# POST :
|
||||||
# Content-Type: application/json;charset=UTF-8
|
# Content-Type: application/json;charset=UTF-8
|
||||||
# User-Agent: FileBoy Net Notifier v1.15
|
# User-Agent: FileBoy Net Notifier v1.16
|
||||||
# Body: {"project_folder":"/project/path","file":"main.go","changed":1576567861913824940,"ext":".go","event":"write"}
|
# Body: {"project_folder":"/project/path","file":"main.go","changed":1576567861913824940,"ext":".go","event":"write"}
|
||||||
# e.g: http://example.com/notifier/fileboy-listener
|
# e.g: http://example.com/notifier/fileboy-listener
|
||||||
# no notice is enabled. Please leave it blank. ""
|
# no notice is enabled. Please leave it blank. ""
|
||||||
|
@@ -12,11 +12,11 @@ func getPidFile() string {
|
|||||||
return projectFolder + "/.fileboy.pid"
|
return projectFolder + "/.fileboy.pid"
|
||||||
}
|
}
|
||||||
|
|
||||||
func runAsDeamon() (int, error) {
|
func runAsDaemon() (int, error) {
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
logAndExit("daemons mode cannot run on windows.")
|
logAndExit("daemons mode cannot run on windows.")
|
||||||
}
|
}
|
||||||
err := stopDeamon()
|
err := stopDaemon()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logAndExit(err)
|
logAndExit(err)
|
||||||
}
|
}
|
||||||
@@ -24,22 +24,22 @@ func runAsDeamon() (int, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
logAndExit("cannot found `fileboy` command in the PATH")
|
logAndExit("cannot found `fileboy` command in the PATH")
|
||||||
}
|
}
|
||||||
deamon := exec.Command("fileboy")
|
daemon := exec.Command("fileboy")
|
||||||
deamon.Dir = projectFolder
|
daemon.Dir = projectFolder
|
||||||
deamon.Env = os.Environ()
|
daemon.Env = os.Environ()
|
||||||
deamon.Stdout = os.Stdout
|
daemon.Stdout = os.Stdout
|
||||||
err = deamon.Start()
|
err = daemon.Start()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logAndExit(err)
|
logAndExit(err)
|
||||||
}
|
}
|
||||||
pid := deamon.Process.Pid
|
pid := daemon.Process.Pid
|
||||||
if pid != 0 {
|
if pid != 0 {
|
||||||
ioutil.WriteFile(getPidFile(), []byte(strconv.Itoa(pid)), 0644)
|
ioutil.WriteFile(getPidFile(), []byte(strconv.Itoa(pid)), 0644)
|
||||||
}
|
}
|
||||||
return pid, nil
|
return pid, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func stopDeamon() error {
|
func stopDaemon() error {
|
||||||
bs, err := ioutil.ReadFile(getPidFile())
|
bs, err := ioutil.ReadFile(getPidFile())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
@@ -48,3 +48,9 @@ func stopDeamon() error {
|
|||||||
os.Remove(getPidFile())
|
os.Remove(getPidFile())
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func stopSelf() {
|
||||||
|
pid := os.Getpid()
|
||||||
|
os.Remove(getPidFile())
|
||||||
|
_ = exec.Command("kill", strconv.Itoa(pid)).Run()
|
||||||
|
}
|
60
fileboy.go
60
fileboy.go
@@ -1,3 +1,7 @@
|
|||||||
|
// Copyright (c) 2018-2020 Author dengsgo<dengsgo@yoytang.com> [https://github.com/dengsgo/fileboy]
|
||||||
|
// Distributed under the MIT software license, see the accompanying
|
||||||
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -6,9 +10,11 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
|
"os/signal"
|
||||||
"path"
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gopkg.in/fsnotify/fsnotify.v1"
|
"gopkg.in/fsnotify/fsnotify.v1"
|
||||||
@@ -111,6 +117,11 @@ func eventDispatcher(event fsnotify.Event) {
|
|||||||
func addWatcher() {
|
func addWatcher() {
|
||||||
logInfo("collecting directory information...")
|
logInfo("collecting directory information...")
|
||||||
dirsMap := map[string]bool{}
|
dirsMap := map[string]bool{}
|
||||||
|
for _, dir := range cfg.Monitor.ExceptDirs {
|
||||||
|
if dir == "." {
|
||||||
|
logAndExit("exceptDirs must is not project root path ! err path:", dir)
|
||||||
|
}
|
||||||
|
}
|
||||||
for _, dir := range cfg.Monitor.IncludeDirs {
|
for _, dir := range cfg.Monitor.IncludeDirs {
|
||||||
darr := dirParse2Array(dir)
|
darr := dirParse2Array(dir)
|
||||||
if len(darr) < 1 || len(darr) > 2 {
|
if len(darr) < 1 || len(darr) > 2 {
|
||||||
@@ -145,16 +156,7 @@ func addWatcher() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
for _, dir := range cfg.Monitor.ExceptDirs {
|
|
||||||
if dir == "." {
|
|
||||||
logAndExit("exceptDirs must is not project root path ! err path:", dir)
|
|
||||||
}
|
|
||||||
p := projectFolder + "/" + dir
|
|
||||||
delete(dirsMap, p)
|
|
||||||
listFile(p, func(d string) {
|
|
||||||
delete(dirsMap, d)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
for dir := range dirsMap {
|
for dir := range dirsMap {
|
||||||
logInfo("watcher add -> ", dir)
|
logInfo("watcher add -> ", dir)
|
||||||
err := watcher.Add(dir)
|
err := watcher.Add(dir)
|
||||||
@@ -200,6 +202,15 @@ func initWatcher() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func watchChangeHandler(event fsnotify.Event) {
|
func watchChangeHandler(event fsnotify.Event) {
|
||||||
|
// stop the fileboy daemon process when the .fileboy.pid file is changed
|
||||||
|
if event.Name == getPidFile() &&
|
||||||
|
(event.Op == fsnotify.Remove ||
|
||||||
|
event.Op == fsnotify.Write ||
|
||||||
|
event.Op == fsnotify.Rename) {
|
||||||
|
logUInfo("exit daemon process")
|
||||||
|
stopSelf()
|
||||||
|
return
|
||||||
|
}
|
||||||
if event.Op != fsnotify.Create && event.Op != fsnotify.Rename {
|
if event.Op != fsnotify.Create && event.Op != fsnotify.Rename {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -213,13 +224,7 @@ func watchChangeHandler(event fsnotify.Event) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// check exceptDirs
|
// check exceptDirs
|
||||||
has := false
|
if hitDirs(event.Name, &cfg.Monitor.ExceptDirs) {
|
||||||
for _, v := range cfg.Monitor.ExceptDirs {
|
|
||||||
if strings.HasPrefix(event.Name, projectFolder+"/"+v) {
|
|
||||||
has = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if has {
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,8 +270,8 @@ func parseArgs() {
|
|||||||
case len(os.Args) > 1:
|
case len(os.Args) > 1:
|
||||||
c := os.Args[1]
|
c := os.Args[1]
|
||||||
switch c {
|
switch c {
|
||||||
case "deamon":
|
case "deamon", "daemon":
|
||||||
pid, err := runAsDeamon()
|
pid, err := runAsDaemon()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logAndExit(err)
|
logAndExit(err)
|
||||||
}
|
}
|
||||||
@@ -274,7 +279,7 @@ func parseArgs() {
|
|||||||
logUInfo("fileboy is ready. the main process will run as a daemons")
|
logUInfo("fileboy is ready. the main process will run as a daemons")
|
||||||
return
|
return
|
||||||
case "stop":
|
case "stop":
|
||||||
err := stopDeamon()
|
err := stopDaemon()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logAndExit(err)
|
logAndExit(err)
|
||||||
}
|
}
|
||||||
@@ -310,6 +315,20 @@ func parseArgs() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func signalHandler() {
|
||||||
|
c := make(chan os.Signal)
|
||||||
|
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
||||||
|
go func() {
|
||||||
|
<-c
|
||||||
|
if taskMan != nil && taskMan.cmd != nil && taskMan.cmd.Process != nil {
|
||||||
|
if err := taskMan.cmd.Process.Kill(); err != nil {
|
||||||
|
logWarn("stopping the process failed: PID:", taskMan.cmd.ProcessState.Pid(), ":", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
os.Exit(0)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
func getFileGirlPath() string {
|
func getFileGirlPath() string {
|
||||||
return projectFolder + "/" + filegirlYamlName
|
return projectFolder + "/" + filegirlYamlName
|
||||||
}
|
}
|
||||||
@@ -332,5 +351,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
logAndExit(err)
|
logAndExit(err)
|
||||||
}
|
}
|
||||||
|
signalHandler()
|
||||||
parseArgs()
|
parseArgs()
|
||||||
}
|
}
|
||||||
|
@@ -1,3 +1,7 @@
|
|||||||
|
// Copyright (c) 2018-2020 Author dengsgo<dengsgo@yoytang.com> [https://github.com/dengsgo/fileboy]
|
||||||
|
// Distributed under the MIT software license, see the accompanying
|
||||||
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
type FileGirl struct {
|
type FileGirl struct {
|
||||||
|
4
go.mod
4
go.mod
@@ -3,7 +3,7 @@ module fileboy
|
|||||||
go 1.13
|
go 1.13
|
||||||
|
|
||||||
require (
|
require (
|
||||||
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527 // indirect
|
golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211 // indirect
|
||||||
gopkg.in/fsnotify/fsnotify.v1 v1.4.7
|
gopkg.in/fsnotify/fsnotify.v1 v1.4.7
|
||||||
gopkg.in/yaml.v2 v2.2.8
|
gopkg.in/yaml.v2 v2.3.0
|
||||||
)
|
)
|
||||||
|
6
go.sum
6
go.sum
@@ -1,7 +1,13 @@
|
|||||||
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527 h1:uYVVQ9WP/Ds2ROhcaGPeIdVq0RIXVLwsHlnvJ+cT1So=
|
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527 h1:uYVVQ9WP/Ds2ROhcaGPeIdVq0RIXVLwsHlnvJ+cT1So=
|
||||||
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200408040146-ea54a3c99b9b h1:h03Ur1RlPrGTjua4koYdpGl8W0eYo8p1uI9w7RPlkdk=
|
||||||
|
golang.org/x/sys v0.0.0-20200408040146-ea54a3c99b9b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211 h1:9UQO31fZ+0aKQOFldThf7BKPMJTiBfWycGh/u3UoO88=
|
||||||
|
golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/fsnotify/fsnotify.v1 v1.4.7 h1:XNNYLJHt73EyYiCZi6+xjupS9CpvmiDgjPTAjrBlQbo=
|
gopkg.in/fsnotify/fsnotify.v1 v1.4.7 h1:XNNYLJHt73EyYiCZi6+xjupS9CpvmiDgjPTAjrBlQbo=
|
||||||
gopkg.in/fsnotify/fsnotify.v1 v1.4.7/go.mod h1:Fyux9zXlo4rWoMSIzpn9fDAYjalPqJ/K1qJ27s+7ltE=
|
gopkg.in/fsnotify/fsnotify.v1 v1.4.7/go.mod h1:Fyux9zXlo4rWoMSIzpn9fDAYjalPqJ/K1qJ27s+7ltE=
|
||||||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
||||||
|
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
@@ -1,3 +1,7 @@
|
|||||||
|
// Copyright (c) 2018-2020 Author dengsgo<dengsgo@yoytang.com> [https://github.com/dengsgo/fileboy]
|
||||||
|
// Distributed under the MIT software license, see the accompanying
|
||||||
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -61,7 +65,7 @@ func (n *NetNotifier) dispatch(params *postParams) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
req.Header.Set("Content-Type", "application/json;charset=UTF-8")
|
req.Header.Set("Content-Type", "application/json;charset=UTF-8")
|
||||||
req.Header.Set("User-Agent", "FileBoy Net Notifier v1.15")
|
req.Header.Set("User-Agent", "FileBoy Net Notifier v1.16")
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logError("notifier call failed. err:", err)
|
logError("notifier call failed. err:", err)
|
||||||
|
10
raw.go
10
raw.go
@@ -76,7 +76,7 @@ notifier:
|
|||||||
# 请求超时 15 秒
|
# 请求超时 15 秒
|
||||||
# POST 格式:
|
# POST 格式:
|
||||||
# Content-Type: application/json;charset=UTF-8
|
# Content-Type: application/json;charset=UTF-8
|
||||||
# User-Agent: FileBoy Net Notifier v1.15
|
# User-Agent: FileBoy Net Notifier v1.16
|
||||||
# Body: {"project_folder":"/project/path","file":"main.go","changed":1576567861913824940,"ext":".go","event":"write"}
|
# Body: {"project_folder":"/project/path","file":"main.go","changed":1576567861913824940,"ext":".go","event":"write"}
|
||||||
# 例: http://example.com/notifier/fileboy-listener
|
# 例: http://example.com/notifier/fileboy-listener
|
||||||
# 不启用通知,请留空 ""
|
# 不启用通知,请留空 ""
|
||||||
@@ -112,7 +112,7 @@ Usage of fileboy:
|
|||||||
初始化 fileboy, 在当前目录生成 filegirl.yaml 配置文件
|
初始化 fileboy, 在当前目录生成 filegirl.yaml 配置文件
|
||||||
exec
|
exec
|
||||||
尝试运行定义的 command 命令
|
尝试运行定义的 command 命令
|
||||||
deamon
|
daemon
|
||||||
读取当前目录下的 filegirl.yaml 配置,以守护进程的方式运行在后台
|
读取当前目录下的 filegirl.yaml 配置,以守护进程的方式运行在后台
|
||||||
stop
|
stop
|
||||||
停止守护进程
|
停止守护进程
|
||||||
@@ -139,13 +139,13 @@ var logo = `
|
|||||||
_____ _ | | _____ ____) ) | | | |___| |
|
_____ _ | | _____ ____) ) | | | |___| |
|
||||||
| ___) | | | | | ___) | __ (| | | |\_____/
|
| ___) | | | | | ___) | __ (| | | |\_____/
|
||||||
| | _| |_| |_____| |_____| |__) ) |___| | ___
|
| | _| |_| |_____| |_____| |__) ) |___| | ___
|
||||||
|_| (_____)_______)_______)______/ \_____/ (___) V1.15
|
|_| (_____)_______)_______)______/ \_____/ (___) V1.16
|
||||||
`
|
`
|
||||||
var statement = `Dengsgo [dengsgo@gmail.com] Open Source with MIT License`
|
var statement = `Dengsgo [dengsgo@gmail.com] Open Source with MIT License`
|
||||||
|
|
||||||
var versionDesc = `
|
var versionDesc = `
|
||||||
Version fileboy: v1.15 filegirl: v` + strconv.Itoa(Version) + `
|
Version fileboy: v1.16 filegirl: v` + strconv.Itoa(Version) + `
|
||||||
Released 2020.03.08
|
Released 2020.10.17
|
||||||
Licence MIT
|
Licence MIT
|
||||||
Author dengsgo [dengsgo@gmail.com]
|
Author dengsgo [dengsgo@gmail.com]
|
||||||
Website https://github.com/dengsgo/fileboy
|
Website https://github.com/dengsgo/fileboy
|
||||||
|
BIN
resources/icon.png
Normal file
BIN
resources/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.8 KiB |
8
snapcraft.yaml
Normal file
8
snapcraft.yaml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
name: fileboy
|
||||||
|
vendor: dengsgo, https://github.com/dengsgo, <dengsgo@yoytang.com>
|
||||||
|
summary: File Change Monitoring Notification Tools.
|
||||||
|
description: File Change Monitoring Notification Tools. Please Visit https://github.com/dengsgo/fileboy
|
||||||
|
version: 1.15
|
||||||
|
icon: resources/icon.png
|
||||||
|
base: core18
|
||||||
|
grade: stable
|
19
taskman.go
19
taskman.go
@@ -1,3 +1,7 @@
|
|||||||
|
// Copyright (c) 2018-2020 Author dengsgo<dengsgo@yoytang.com> [https://github.com/dengsgo/fileboy]
|
||||||
|
// Distributed under the MIT software license, see the accompanying
|
||||||
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -30,14 +34,15 @@ func newTaskMan(delay int, callUrl string) *TaskMan {
|
|||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
<-t.waitChan
|
<-t.waitChan
|
||||||
if len(t.waitQueue) > 0 {
|
if len(t.waitQueue) < 1 {
|
||||||
cf := t.waitQueue[len(t.waitQueue)-1]
|
return
|
||||||
if len(t.waitQueue) > 1 {
|
|
||||||
logInfo("redundant tasks dropped:", len(t.waitQueue)-1)
|
|
||||||
}
|
|
||||||
t.waitQueue = []*changedFile{}
|
|
||||||
go t.preRun(cf)
|
|
||||||
}
|
}
|
||||||
|
cf := t.waitQueue[len(t.waitQueue)-1]
|
||||||
|
if len(t.waitQueue) > 1 {
|
||||||
|
logInfo("redundant tasks dropped:", len(t.waitQueue)-1)
|
||||||
|
}
|
||||||
|
t.waitQueue = []*changedFile{}
|
||||||
|
go t.preRun(cf)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
13
util.go
13
util.go
@@ -53,11 +53,24 @@ func dirParse2Array(s string) []string {
|
|||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func hitDirs(d string, dirs *[]string) bool {
|
||||||
|
d += "/"
|
||||||
|
for _, v := range *dirs {
|
||||||
|
if strings.HasPrefix(d, projectFolder+"/"+v+"/") {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func listFile(folder string, fun func(string)) {
|
func listFile(folder string, fun func(string)) {
|
||||||
files, _ := ioutil.ReadDir(folder)
|
files, _ := ioutil.ReadDir(folder)
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
if file.IsDir() {
|
if file.IsDir() {
|
||||||
d := folder + "/" + file.Name()
|
d := folder + "/" + file.Name()
|
||||||
|
if hitDirs(d, &cfg.Monitor.ExceptDirs) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
fun(d)
|
fun(d)
|
||||||
listFile(d, fun)
|
listFile(d, fun)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user