storagenode/updater: read identity location from storagenode's config.yaml (#3607)

This commit is contained in:
Kaloyan Raev 2019-11-22 15:57:37 +02:00 committed by GitHub
parent 77d4add101
commit bb16c07dc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 10 deletions

View File

@ -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:

View File

@ -57,7 +57,7 @@
Account="[SERVICEACCOUNT]"
Password="[SERVICEPASSWORD]"
ErrorControl="normal"
Arguments="run --config-dir &quot;[INSTALLFOLDER]\&quot; --identity-dir &quot;[IDENTITYDIR]\&quot; --binary-location &quot;[INSTALLFOLDER]\storagenode.exe&quot; --log &quot;[INSTALLFOLDER]\storagenode-updater.log&quot;">
Arguments="run --config-dir &quot;[INSTALLFOLDER]\&quot; --binary-location &quot;[INSTALLFOLDER]storagenode.exe&quot; --log &quot;[INSTALLFOLDER]storagenode-updater.log&quot;">
<util:ServiceConfig
ServiceName="storagenode-updater"
ResetPeriodInDays="1"