Skip to content

Commit 6cb1746

Browse files
committed
Adding install.RestartService
1 parent 06be899 commit 6cb1746

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

internal/pkg/agent/application/upgrade/rollback.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,9 @@ func restartAgent(ctx context.Context) error {
145145

146146
restartViaServiceFn := func(ctx context.Context) error {
147147
topPath := paths.Top()
148-
install.StopService(topPath)
149-
err := install.StartService(topPath)
148+
err := install.RestartService(topPath)
150149
if err != nil {
151-
return err
150+
return fmt.Errorf("failed to restart agent via service: %w", err)
152151
}
153152

154153
return nil

internal/pkg/agent/install/install.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,16 @@ func StopService(topPath string) error {
172172
return nil
173173
}
174174

175+
// RestartService stops and starts the installed service.
176+
func RestartService(topPath string) error {
177+
err := StopService(topPath)
178+
if err != nil {
179+
return err
180+
}
181+
182+
return StartService(topPath)
183+
}
184+
175185
// FixPermissions fixes the permissions on the installed system.
176186
func FixPermissions(topPath string) error {
177187
return fixPermissions(topPath)

0 commit comments

Comments
 (0)