github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/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  func init() {
    21  	featureflag.SetFlagsFromRegistry(osenv.JujuRegistryKey, osenv.JujuFeatureFlagEnvKey)
    22  }
    23  
    24  func main() {
    25  	isInteractive, err := svc.IsAnInteractiveSession()
    26  	if err != nil {
    27  		fmt.Fprintf(os.Stderr, "error: %v\n", err)
    28  		os.Exit(1)
    29  	}
    30  
    31  	commandName := filepath.Base(os.Args[0])
    32  	if isInteractive || commandName != names.Jujud {
    33  		os.Exit(Main(os.Args))
    34  	} else {
    35  		s := service.SystemService{
    36  			Name: "jujud",
    37  			Cmd:  Main,
    38  			Args: os.Args,
    39  		}
    40  		if err := s.Run(); err != nil {
    41  			fmt.Fprintf(os.Stderr, "error: %v\n", err)
    42  			os.Exit(1)
    43  		}
    44  		os.Exit(0)
    45  	}
    46  }