-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement dedicated services, enhance integration tests, ensure ranch…
…er-wins can restart in all scenarios
- Loading branch information
1 parent
49f6756
commit 05232b7
Showing
11 changed files
with
283 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package service | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/rancher/wins/pkg/defaults" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
type RancherWinsService struct { | ||
Service | ||
} | ||
|
||
func OpenRancherWinsService() (*RancherWinsService, bool, error) { | ||
|
||
winsSvc, exists, err := Open(defaults.WindowsServiceName) | ||
if err != nil { | ||
return nil, false, fmt.Errorf("error encountered opening %s service: %w", defaults.WindowsServiceName, err) | ||
} | ||
|
||
if !exists { | ||
return nil, false, fmt.Errorf("%s service does not exist", defaults.WindowsServiceName) | ||
} | ||
|
||
x := &RancherWinsService{ | ||
*winsSvc, | ||
} | ||
|
||
return x, exists, nil | ||
} | ||
|
||
func (rw *RancherWinsService) ConfigureDelayedStart(enabled bool) error { | ||
logrus.Infof("%s service has delayed auto start configured: %t", defaults.WindowsServiceName, rw.Config.DelayedAutoStart) | ||
if rw.Config.DelayedAutoStart != enabled { | ||
logrus.Infof("updating %s delayed auto start setting to %t", defaults.WindowsServiceName, enabled) | ||
rw.Config.DelayedAutoStart = enabled | ||
err := rw.UpdateConfig() | ||
if err != nil { | ||
return fmt.Errorf("failed to update %s service configuration while configuring service start type: %w", defaults.WindowsServiceName, err) | ||
} | ||
} else { | ||
logrus.Infof("%s delayed start already set to %t, nothing to do", defaults.WindowsServiceName, enabled) | ||
} | ||
return nil | ||
} |
Oops, something went wrong.