fix:puller.go init function change p.Plugin to plugin

feature:auto init shutdown.sh or shutdown.bat when program start
This commit is contained in:
pg
2025-01-02 19:15:48 +08:00
committed by pggiroro
parent 0caba3d496
commit cbe9f2d645
4 changed files with 32 additions and 1 deletions

14
pkg/util/linux.go Normal file
View File

@@ -0,0 +1,14 @@
//go:build !windows
// +build !windows
package util
import (
"fmt"
"io/ioutil"
"os"
)
func CreateShutdownScript() error {
return ioutil.WriteFile("shutdown.sh", []byte(fmt.Sprintf("kill -9 %d", os.Getpid())), 0777)
}

14
pkg/util/windows.go Normal file
View File

@@ -0,0 +1,14 @@
//go:build windows
// +build windows
package util
import (
"fmt"
"io/ioutil"
"os"
)
func CreateShutdownScript() error {
return ioutil.WriteFile("shutdown.bat", []byte(fmt.Sprintf("taskkill /pid %d -t -f", os.Getpid())), 0777)
}

View File

@@ -83,7 +83,7 @@ func (p *PullJob) GetPullJob() *PullJob {
func (p *PullJob) Init(puller IPuller, plugin *Plugin, streamPath string, conf config.Pull, pubConf *config.Publish) *PullJob {
if pubConf == nil {
p.PublishConfig = p.Plugin.GetCommonConf().Publish
p.PublishConfig = plugin.GetCommonConf().Publish
} else {
p.PublishConfig = *pubConf
}

View File

@@ -191,6 +191,9 @@ func (l errLogger) Println(v ...interface{}) {
}
func (s *Server) Start() (err error) {
if err = util.CreateShutdownScript(); err != nil {
s.Error("create shutdown script error:", err)
}
s.Server = s
s.handler = s
httpConf, tcpConf := &s.config.HTTP, &s.config.TCP