storagenode/updater: read identity location from storagenode's config.yaml (#3607)
This commit is contained in:
parent
77d4add101
commit
bb16c07dc2
@ -16,7 +16,10 @@ import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"golang.org/x/sync/errgroup"
|
||||
"golang.org/x/sys/windows/svc"
|
||||
|
||||
"storj.io/storj/pkg/process"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -55,12 +58,11 @@ func (m *service) Execute(args []string, r <-chan svc.ChangeRequest, changes cha
|
||||
|
||||
changes <- svc.Status{State: svc.StartPending}
|
||||
|
||||
go func() {
|
||||
err := rootCmd.Execute()
|
||||
if err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}()
|
||||
var group errgroup.Group
|
||||
group.Go(func() error {
|
||||
process.Exec(rootCmd)
|
||||
return nil
|
||||
})
|
||||
|
||||
changes <- svc.Status{State: svc.Running, Accepts: cmdsAccepted}
|
||||
|
||||
@ -75,10 +77,10 @@ func (m *service) Execute(args []string, r <-chan svc.ChangeRequest, changes cha
|
||||
case svc.Stop, svc.Shutdown:
|
||||
log.Println("Stop/Shutdown request received.")
|
||||
changes <- svc.Status{State: svc.StopPending}
|
||||
|
||||
// Cancel the command's root context to cleanup resources
|
||||
_, cancel := process.Ctx(runCmd)
|
||||
cancel()
|
||||
// Sleep some time to give chance for goroutines finish cleanup after cancelling the context
|
||||
time.Sleep(3 * time.Second)
|
||||
_ = group.Wait() // process.Exec does not return an error
|
||||
// After returning the Windows Service is stopped and the process terminates
|
||||
return
|
||||
default:
|
||||
|
@ -57,7 +57,7 @@
|
||||
Account="[SERVICEACCOUNT]"
|
||||
Password="[SERVICEPASSWORD]"
|
||||
ErrorControl="normal"
|
||||
Arguments="run --config-dir "[INSTALLFOLDER]\" --identity-dir "[IDENTITYDIR]\" --binary-location "[INSTALLFOLDER]\storagenode.exe" --log "[INSTALLFOLDER]\storagenode-updater.log"">
|
||||
Arguments="run --config-dir "[INSTALLFOLDER]\" --binary-location "[INSTALLFOLDER]storagenode.exe" --log "[INSTALLFOLDER]storagenode-updater.log"">
|
||||
<util:ServiceConfig
|
||||
ServiceName="storagenode-updater"
|
||||
ResetPeriodInDays="1"
|
||||
|
Loading…
Reference in New Issue
Block a user