github.com/axw/juju@v0.0.0-20161005053422-4bd6544d08d4/cmd/jujud/main_windows.go (about) 1 // Copyright 2015 Canonical Ltd. 2 // Copyright 2015 Cloudbase Solutions 3 // Licensed under the AGPLv3, see LICENCE file for details. 4 5 package main 6 7 import ( 8 "fmt" 9 "os" 10 "path/filepath" 11 12 "github.com/gabriel-samfira/sys/windows/svc" 13 "github.com/juju/utils/featureflag" 14 15 "github.com/juju/juju/cmd/service" 16 "github.com/juju/juju/juju/names" 17 "github.com/juju/juju/juju/osenv" 18 ) 19 20 // FLAGSFROMENVIRONMENT can control whether we read featureflags from the 21 // environment or from the registry. This is only needed because we build the 22 // jujud binary in uniter tests and we cannot mock the registry out easily. 23 // Once uniter tests are fixed this should be removed. 24 var FLAGSFROMENVIRONMENT string 25 26 func init() { 27 if FLAGSFROMENVIRONMENT == "true" { 28 featureflag.SetFlagsFromEnvironment(osenv.JujuFeatureFlagEnvKey) 29 } else { 30 featureflag.SetFlagsFromRegistry(osenv.JujuRegistryKey, osenv.JujuFeatureFlagEnvKey) 31 } 32 } 33 34 func main() { 35 isInteractive, err := svc.IsAnInteractiveSession() 36 if err != nil { 37 fmt.Fprintf(os.Stderr, "error: %v\n", err) 38 os.Exit(1) 39 } 40 41 commandName := filepath.Base(os.Args[0]) 42 if isInteractive || commandName != names.Jujud { 43 os.Exit(Main(os.Args)) 44 } else { 45 s := service.SystemService{ 46 Name: "jujud", 47 Cmd: Main, 48 Args: os.Args, 49 } 50 if err := s.Run(); err != nil { 51 fmt.Fprintf(os.Stderr, "error: %v\n", err) 52 os.Exit(1) 53 } 54 os.Exit(0) 55 } 56 }