コード例 #1
0
ファイル: service.go プロジェクト: Nanocloud/community
func removeService(name string) error {
	log.Info("Removing service")

	m, err := mgr.Connect()
	if err != nil {
		return err
	}
	defer m.Disconnect()
	s, err := m.OpenService(name)
	if err != nil {
		log.Info("Service not installed")
		return ServiceNotFound
	}
	defer s.Close()
	err = s.Delete()
	if err != nil {
		return err
	}
	err = eventlog.Remove(name)
	if err != nil {
		return fmt.Errorf("RemoveEventLogSource() failed: %s", err)
	}
	log.Info("Service removed")
	return nil
}
コード例 #2
0
func uninstallService(name string) {
	log.Infof("Uninstalling service %s", name)
	m, err := mgr.Connect()
	if err != nil {
		log.Errorf("Failed to connect to service manager: %v", err)
	}
	defer m.Disconnect()

	s, err := m.OpenService(name)
	// service exist so we try to uninstall it
	if err != nil {
		log.Debugf("Service %s doesn't exist, no uninstall action needed", name)
		return
	}

	defer s.Close()
	err = s.Delete()
	if err != nil {
		log.Errorf("Can't delete service %s: %v", name, err)
	}

	err = eventlog.Remove(s.Name)
	if err != nil {
		log.Errorf("RemoveEventLogSource() failed: %s", err)
	}

	return
}
コード例 #3
0
func removeEventLog(c *cli.Context) {
	err := eventlog.Remove(lib.ConnectorName)
	if err != nil {
		fmt.Printf("Failed to remove event log registry entries: %s\n", err)
		os.Exit(1)
	}
	fmt.Println("Event log registry entries removed successfully")
}
コード例 #4
0
ファイル: service_windows.go プロジェクト: SUSE/docker.mirror
func unregisterService() error {
	m, err := mgr.Connect()
	if err != nil {
		return err
	}
	defer m.Disconnect()

	s, err := m.OpenService(*flServiceName)
	if err != nil {
		return err
	}
	defer s.Close()

	eventlog.Remove(*flServiceName)
	err = s.Delete()
	if err != nil {
		return err
	}
	return nil
}
コード例 #5
0
ファイル: service_windows.go プロジェクト: sdhjl2000/service
func (ws *windowsService) Uninstall() error {
	m, err := mgr.Connect()
	if err != nil {
		return err
	}
	defer m.Disconnect()
	s, err := m.OpenService(ws.Name)
	if err != nil {
		return fmt.Errorf("service %s is not installed", ws.Name)
	}
	defer s.Close()
	err = s.Delete()
	if err != nil {
		return err
	}
	err = eventlog.Remove(ws.Name)
	if err != nil {
		return fmt.Errorf("RemoveEventLogSource() failed: %s", err)
	}
	return nil
}
コード例 #6
0
ファイル: install.go プロジェクト: procks/direct_print_server
func removeService(name string) error {
	m, err := mgr.Connect()
	if err != nil {
		return err
	}
	defer m.Disconnect()
	s, err := m.OpenService(name)
	if err != nil {
		return fmt.Errorf("service %s is not installed", name)
	}
	defer s.Close()
	err = s.Delete()
	if err != nil {
		return err
	}
	err = eventlog.Remove(name)
	if err != nil {
		return fmt.Errorf("RemoveEventLogSource() failed: %s", err)
	}
	return nil
}
コード例 #7
0
ファイル: log_test.go プロジェクト: 2722/lantern
func TestLog(t *testing.T) {
	if testing.Short() {
		t.Skip("skipping test in short mode - it modifies system logs")
	}

	const name = "mylog"
	const supports = eventlog.Error | eventlog.Warning | eventlog.Info
	err := eventlog.InstallAsEventCreate(name, supports)
	if err != nil {
		t.Fatalf("Install failed: %s", err)
	}
	defer func() {
		err = eventlog.Remove(name)
		if err != nil {
			t.Fatalf("Remove failed: %s", err)
		}
	}()

	l, err := eventlog.Open(name)
	if err != nil {
		t.Fatalf("Open failed: %s", err)
	}
	defer l.Close()

	err = l.Info(1, "info")
	if err != nil {
		t.Fatalf("Info failed: %s", err)
	}
	err = l.Warning(2, "warning")
	if err != nil {
		t.Fatalf("Warning failed: %s", err)
	}
	err = l.Error(3, "error")
	if err != nil {
		t.Fatalf("Error failed: %s", err)
	}
}
コード例 #8
0
ファイル: command_windows.go プロジェクト: hectane/hectane
// Stop the service.
var stopCommand = &command{
	name:        "stop",
	description: "stop the service (Windows only)",
	exec: func(config *cfg.Config) error {
		return serviceCommand("stop")
	},
}

// Remove the service.
var removeCommand = &command{
	name:        "remove",
	description: "remove the service (Windows only)",
	exec: func(config *cfg.Config) error {
		if err := serviceCommand("remove"); err != nil {
			return err
		}
		return eventlog.Remove(exec.ServiceName)
	},
}

// Initialize the commands available for the current platform.
func Init() {
	commands = []*command{
		installCommand,
		removeCommand,
		startCommand,
		stopCommand,
	}
}