Skip to content

Commit

Permalink
refactor(snap)!: Disable and stop services by default (#4552)
Browse files Browse the repository at this point in the history
* Move nginx from oneshot to normal services

* refactor(snap)!: Keep services disabled by default

This is to allow manual env var configuration before first startup

BREAKING CHANGE: Services are not longer started and enabled by default

Signed-off-by: Farshid Tavakolizadeh <[email protected]>
  • Loading branch information
farshidtz authored May 5, 2023
1 parent ddb07c7 commit 6027525
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 23 deletions.
7 changes: 4 additions & 3 deletions snap/local/helper-go/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ const (
var (
securityServices = []string{
vault,
securityNginx,
}
securitySetupServices = []string{
securitySecretStoreSetup,
securityBootstrapperConsul,
securityBootstrapperNginx,
securityProxyAuth,
securityBootstrapperRedis,
securityNginx,
}
coreSetupServices = []string{
coreCommonConfigBootstrapper,
Expand All @@ -66,10 +66,11 @@ func allOneshotServices() (s []string) {
}

func allServices() (s []string) {
s = make([]string, len(coreServices)+len(supportServices)+len(securityServices)+len(allOneshotServices()))
allOneshotServices := allOneshotServices()
s = make([]string, 0, len(coreServices)+len(supportServices)+len(securityServices)+len(allOneshotServices))
s = append(s, coreServices...)
s = append(s, supportServices...)
s = append(s, securityServices...)
s = append(s, allOneshotServices()...)
s = append(s, allOneshotServices...)
return s
}
9 changes: 0 additions & 9 deletions snap/local/helper-go/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,5 @@ func configure() {
log.Fatalf("Error processing autostart options: %v", err)
}

// Unset autostart for oneshot services so they don't start again
var oneshotAutostart []string
for _, s := range allOneshotServices() {
oneshotAutostart = append(oneshotAutostart, "apps."+s+".autostart")
}
if err = snapctl.Unset(oneshotAutostart...).Run(); err != nil {
log.Fatalf("Error unsetting snap option: %v", err)
}

log.Debug("End")
}
11 changes: 0 additions & 11 deletions snap/local/helper-go/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,15 +303,4 @@ func install() {
log.Fatalf("Error installing redis: %v", err)
}

// Enable autostart so that services start by default after seeding configuration
// Set the option for each app instead of globally (i.e. autostart=true), so
// that the option can be selectively unset for oneshot services after starting
// them once!
var autostartKeyValues []string
for _, s := range allServices() {
autostartKeyValues = append(autostartKeyValues, "apps."+s+".autostart", "true")
}
if err = snapctl.Set(autostartKeyValues...).Run(); err != nil {
log.Fatalf("Error setting snap option: %v", err)
}
}

0 comments on commit 6027525

Please sign in to comment.