@@ -81,12 +81,13 @@ func (r *RunCommand) Execute(args []string) (err error) {
8181// InstallCommand used to install a binary as service.
8282type InstallCommand struct {
8383 RootCommand
84- ExePath string `long:"executable" short:"e " description:"Full path to the executable" required:"true"`
84+ ExePath string `long:"executable" short:"x " description:"Full path to the executable" required:"true"`
8585 WorkDir string `long:"workdir" short:"w" description:"Working directory of the executable, if not specified the folder of the executable is used."`
8686 Name string `long:"name" short:"n" description:"Name of the service, if not specified name of the executable is used."`
8787 DisplayName string `long:"display-name" short:"i" description:"Display name of the service, if not specified name of the executable is used."`
8888 Desc string `long:"desc" short:"d" description:"Description of the service"`
8989 Args []string `long:"arg" short:"a" description:"Arguments to pass to the executable in the same order as specified. (ex. -a \"-la\" -a \"123\")"`
90+ Env []string `long:"env" short:"e" description:"Arguments to pass to the executable in the same order as specified. (ex. -a \"-la\" -a \"123\")"`
9091}
9192
9293// Execute will install a binary as service. The args parameter is not used
@@ -109,6 +110,7 @@ func (i *InstallCommand) Execute(args []string) (err error) {
109110 Name : i .Name ,
110111 WorkDir : i .WorkDir ,
111112 Args : i .Args ,
113+ Env : i .Env ,
112114 }
113115
114116 i .logDebug ("Creating configuration file..." )
@@ -241,6 +243,7 @@ type SvcConfig struct {
241243 ExePath string `json:"exe_path,omitempty"`
242244 WorkDir string `json:"work_dir,omitempty"`
243245 Args []string `json:"args,omitempty"`
246+ Env []string `json:"env,omitempty"`
244247 WaitTimeout int `json:"wait_timeout,omitempty"`
245248}
246249
@@ -252,7 +255,7 @@ type cerberusSvc struct {
252255// Execute will be called when the service is started.
253256func (c * cerberusSvc ) Execute (args []string , r <- chan svc.ChangeRequest , changes chan <- svc.Status ) (svcSpecificEC bool , exitCode uint32 ) {
254257 changes <- svc.Status {State : svc .StartPending }
255- cmd := exec.Cmd {Path : c .cfg .ExePath , Dir : c .cfg .WorkDir , Args : c .cfg .Args }
258+ cmd := exec.Cmd {Path : c .cfg .ExePath , Dir : c .cfg .WorkDir , Args : c .cfg .Args , Env : append ( os . Environ (), c . cfg . Env ... ) }
256259 if err := cmd .Start (); err != nil {
257260 c .log .Error (2 , fmt .Sprintf ("Failed to start service: %v" , err ))
258261 return false , 2
0 commit comments