mirror of
https://github.com/langhuihui/monibuca.git
synced 2025-09-27 09:52:06 +08:00
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:
14
pkg/util/linux.go
Normal file
14
pkg/util/linux.go
Normal 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
14
pkg/util/windows.go
Normal 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)
|
||||||
|
}
|
@@ -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 {
|
func (p *PullJob) Init(puller IPuller, plugin *Plugin, streamPath string, conf config.Pull, pubConf *config.Publish) *PullJob {
|
||||||
if pubConf == nil {
|
if pubConf == nil {
|
||||||
p.PublishConfig = p.Plugin.GetCommonConf().Publish
|
p.PublishConfig = plugin.GetCommonConf().Publish
|
||||||
} else {
|
} else {
|
||||||
p.PublishConfig = *pubConf
|
p.PublishConfig = *pubConf
|
||||||
}
|
}
|
||||||
|
@@ -191,6 +191,9 @@ func (l errLogger) Println(v ...interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) Start() (err error) {
|
func (s *Server) Start() (err error) {
|
||||||
|
if err = util.CreateShutdownScript(); err != nil {
|
||||||
|
s.Error("create shutdown script error:", err)
|
||||||
|
}
|
||||||
s.Server = s
|
s.Server = s
|
||||||
s.handler = s
|
s.handler = s
|
||||||
httpConf, tcpConf := &s.config.HTTP, &s.config.TCP
|
httpConf, tcpConf := &s.config.HTTP, &s.config.TCP
|
||||||
|
Reference in New Issue
Block a user