fix: финализация fix6 для production runtime и reconfigure

This commit is contained in:
2026-04-28 17:29:23 +05:00
parent 607689df9b
commit 087d9f616a
11 changed files with 34 additions and 85 deletions
-58
View File
@@ -1,58 +0,0 @@
package proxy
import (
"errors"
"github.com/sirupsen/logrus"
"hy2xs-admin/model/constant"
"hy2xs-admin/util"
"os/exec"
"sync"
)
type Hysteria2Process struct {
process
binPath string
configPath string
}
var mutexHysteria2 sync.Mutex
var cmdHysteria2 exec.Cmd
var hysteria2Instance *Hysteria2Process
func init() {
hysteria2Instance = &Hysteria2Process{process{mutex: &mutexHysteria2, cmd: &cmdHysteria2}, util.GetHysteria2BinPath(), constant.Hysteria2ConfigPath}
}
func NewHysteria2Instance() *Hysteria2Process {
return hysteria2Instance
}
func (h *Hysteria2Process) IsRunning() bool {
return h.isRunning()
}
func (h *Hysteria2Process) StartHysteria2() error {
if err := h.start(h.binPath, "-c", h.configPath, "server"); err != nil {
_ = util.RemoveFile(h.configPath)
logrus.Errorf("start hysteria2 err: %v", err)
return errors.New("start hysteria2 err")
}
return nil
}
func (h *Hysteria2Process) StopHysteria2() error {
if err := h.stop(); err != nil {
logrus.Errorf("stop hysteria2 err: %v", err)
return errors.New("stop hysteria2 err")
}
_ = util.RemoveFile(h.configPath)
return nil
}
func (h *Hysteria2Process) Release() error {
if err := h.release(); err != nil {
logrus.Errorf("release hysteria2 err: %v", err)
return errors.New("release hysteria2 err")
}
return nil
}