func (c *Concierge) CreateService() error {
	m, err := mgr.Connect()
	if err != nil {
		return errors.Wrap(err, "could not open SCM")
	}
	defer m.Disconnect()

	service, err := m.CreateService(c.name, c.path, mgr.Config{
		ServiceType:    windows.SERVICE_WIN32_OWN_PROCESS,
		StartType:      mgr.StartAutomatic,
		ErrorControl:   mgr.ErrorNormal,
		BinaryPathName: c.path,
		Description:    c.cfg.Description,
		DisplayName:    c.cfg.DisplayName,
	}, c.cfg.Args...)

	defer service.Close()

	if err != nil {
		return errors.Wrap(err, "error creating the service")
	}

	recoveryActions := []mgr.RecoveryAction{
		{
			Type:  mgr.ServiceRestart,
			Delay: 10000,
		},
	}
	if err := c.registerEnvVars(); err != nil {
		return err
	}

	return service.SetRecoveryActions(recoveryActions, 0)
}
// CreateService configures the Windows service correctly, returning the service.
CreateService configures the Windows service correctly, returning the service.
// CreateService configures the Windows service correctly returning the service .
func (c *Concierge) CreateService() error {
	m, err := mgr.Connect()
	if err != nil {
		return errors.Wrap(err, "could not open SCM")
	}
	defer m.Disconnect()
	service, err := m.CreateService(c.name, c.path, mgr.Config{
		ServiceType:    windows.SERVICE_WIN32_OWN_PROCESS,
		StartType:      mgr.StartAutomatic,
		ErrorControl:   mgr.ErrorNormal,
		BinaryPathName: c.path,
		Description:    c.cfg.Description,
		DisplayName:    c.cfg.DisplayName,
	}, c.cfg.Args...)
	defer service.Close()
	if err != nil {
		return errors.Wrap(err, "error creating the service")
	}
	recoveryActions := []mgr.RecoveryAction{
		{
			Type:  mgr.ServiceRestart,
			Delay: 10000,
		},
	}
	if err := c.registerEnvVars(); err != nil {
		return err
	}
	return service.SetRecoveryActions(recoveryActions, 0)
}
func ( c * Concierge ) CreateService ( ) error { m , err := mgr . Connect ( ) if err != nil { return errors . Wrap ( err , " " ) } defer m . Disconnect ( ) service , err := m . CreateService ( c . name , c . path , mgr . Config { ServiceType : windows . SERVICE_WIN32_OWN_PROCESS , StartType : mgr . StartAutomatic , ErrorControl : mgr . ErrorNormal , BinaryPathName : c . path , Description : c . cfg . Description , DisplayName : c . cfg . DisplayName , } , c . cfg . Args ... ) defer service . Close ( ) if err != nil { return errors . Wrap ( err , " " ) } recoveryActions := [ ] mgr . RecoveryAction { { Type : mgr . ServiceRestart , Delay : 10000 , } , } if err := c . registerEnvVars ( ) ; err != nil { return err } return service . SetRecoveryActions ( recoveryActions , 0 ) }
CreateService configures the Windows service correctly, returning the service.
CreateService configures the Windows service correctly returning the service .