셀프 업데이트 작업 추가 by script

This commit is contained in:
2024-11-12 11:53:18 +09:00
parent 92432fcd83
commit 592e00b98b
5 changed files with 44 additions and 86 deletions

View File

@ -414,7 +414,7 @@ func NewClient(standalone bool) (HoustonClient, error) {
op.ReportDeployingProgress(ctx, dp)
}); err == nil {
if dr.Name == "houston" {
// houston.update 다운로드가 완료되었으므로 종료
// houston_update_dir 다운로드가 완료되었으므로 종료
// 종료되고나면 스크립트가 알아서 재 실행
hc.Shutdown()
return

View File

@ -25,6 +25,10 @@ import (
"golang.org/x/text/transform"
)
const (
houston_update_dir = "./houston.update"
)
func pof2(x int64, min int64) (out int64) {
out = 1
org := x
@ -217,13 +221,7 @@ func (hc *houstonClient) prepareDeploy(name string, version string) (destPath st
}()
verpath := path.Join(hc.config.StorageRoot, name, version)
if _, err := os.Stat(verpath); os.IsNotExist(err) {
// 없네? 만들면 된다.
err = os.MkdirAll(verpath, 0775)
if err != nil {
return "", err
}
} else {
if _, err := os.Stat(verpath); !os.IsNotExist(err) {
// 있네? 재배포 가능한가?
for _, child := range hc.childProcs {
if child.version == version && child.name == name {
@ -287,8 +285,10 @@ func (hc *houstonClient) deploy(req *shared.DeployRequest, cb func(*protos.Deplo
var root string
if req.Name == "houston" {
// houston은 버전없이 houston.update폴더로 다운로드
root = "./houston.update"
// houston은 버전없이 houston_update_dir폴더로 다운로드
root = houston_update_dir
// 이미 houston_update_dir가 있을 수도 있으므로 폴더채로 삭제
os.RemoveAll(houston_update_dir)
} else {
root, err = hc.prepareDeploy(req.Name, req.Version)
if err != nil {
@ -296,6 +296,11 @@ func (hc *houstonClient) deploy(req *shared.DeployRequest, cb func(*protos.Deplo
}
}
err = os.MkdirAll(root, 0775)
if err != nil {
return err
}
// verpath에 배포 시작
h := md5.New()
h.Write([]byte(strings.Trim(req.Url, "/")))