latest 버전 옵션을 프로세스 재시작시에도 적용
This commit is contained in:
@ -91,16 +91,17 @@ type HoustonClient interface {
|
|||||||
var seq = int32(1)
|
var seq = int32(1)
|
||||||
|
|
||||||
type procmeta struct {
|
type procmeta struct {
|
||||||
id int32
|
id int32
|
||||||
cmd *exec.Cmd
|
cmd *exec.Cmd
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
version string
|
version string
|
||||||
verpath string
|
verpath string
|
||||||
recover bool
|
recover bool
|
||||||
state int32
|
state int32
|
||||||
stdin io.WriteCloser
|
stdin io.WriteCloser
|
||||||
logfile string
|
logfile string
|
||||||
|
keepLatest bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pm *procmeta) isState(s protos.ProcessState) bool {
|
func (pm *procmeta) isState(s protos.ProcessState) bool {
|
||||||
@ -362,6 +363,10 @@ func NewClient(standalone bool) (HoustonClient, error) {
|
|||||||
proc.cmd.Process.Release()
|
proc.cmd.Process.Release()
|
||||||
|
|
||||||
if proc.isState(protos.ProcessState_Restart) {
|
if proc.isState(protos.ProcessState_Restart) {
|
||||||
|
if proc.keepLatest {
|
||||||
|
proc.version = "latest"
|
||||||
|
}
|
||||||
|
|
||||||
if err := hc.startChildProcess(&shared.StartProcessRequest{
|
if err := hc.startChildProcess(&shared.StartProcessRequest{
|
||||||
Version: proc.version,
|
Version: proc.version,
|
||||||
Name: proc.name,
|
Name: proc.name,
|
||||||
|
|||||||
@ -150,6 +150,7 @@ func prepareProcessLaunch(storageRoot string, req *shared.StartProcessRequest) (
|
|||||||
return nil, errors.New("args is empty")
|
return nil, errors.New("args is empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foundVersion := req.Version
|
||||||
if req.Version == "latest" {
|
if req.Version == "latest" {
|
||||||
entries, err := os.ReadDir(path.Join(storageRoot, req.Name))
|
entries, err := os.ReadDir(path.Join(storageRoot, req.Name))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -175,11 +176,11 @@ func prepareProcessLaunch(storageRoot string, req *shared.StartProcessRequest) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(latestVersion) > 0 {
|
if len(latestVersion) > 0 {
|
||||||
req.Version = latestVersion
|
foundVersion = latestVersion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
verpath := path.Join(storageRoot, req.Name, req.Version)
|
verpath := path.Join(storageRoot, req.Name, foundVersion)
|
||||||
fi, err := os.Stat(verpath)
|
fi, err := os.Stat(verpath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -210,16 +211,17 @@ func prepareProcessLaunch(storageRoot string, req *shared.StartProcessRequest) (
|
|||||||
|
|
||||||
seq++
|
seq++
|
||||||
return &procmeta{
|
return &procmeta{
|
||||||
id: seq,
|
id: seq,
|
||||||
cmd: cmd,
|
cmd: cmd,
|
||||||
name: req.Name,
|
name: req.Name,
|
||||||
args: req.Args,
|
args: req.Args,
|
||||||
version: req.Version,
|
version: foundVersion,
|
||||||
recover: req.AutoRestart,
|
recover: req.AutoRestart,
|
||||||
verpath: verpath,
|
verpath: verpath,
|
||||||
state: int32(protos.ProcessState_Stopped),
|
state: int32(protos.ProcessState_Stopped),
|
||||||
stdin: stdin,
|
stdin: stdin,
|
||||||
logfile: req.OutputLogFile,
|
logfile: req.OutputLogFile,
|
||||||
|
keepLatest: req.Version == "latest",
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
return nil, errors.New("not found")
|
return nil, errors.New("not found")
|
||||||
|
|||||||
Reference in New Issue
Block a user