kardianos / service

Run go programs as a service on major platforms.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

v1.2.2 regression for windows service

adam-mateen opened this issue · comments

commented

My windows service works with v1.2.1, but not v1.2.2.
Using v.1.2.2 the "Start-Service" command in powershell will timeout with a. generic failure:

Start-Service : Service 'FooService (foo_service)' cannot be started due to the following
error: Cannot start service foo_service on computer '.'.

This is because this commit:
380dcf8
causes a regression.

With v1.2.1 my program can start a "windows service" running process A.
process A then immediately runs cmd := exec.Command() and cmd.CombinedOutput() to start process B.

In v.1.2.1 process B was considered NOT INTERACTIVE, and so it could run this code:

	svcConfig := &service.Config{
		Name:        "GoServiceExampleSimple",
		DisplayName: "Go Service Example",
		Description: "This is an example Go service.",
	}

	prg := &program{}
	s, err := service.New(prg, svcConfig)
	if err != nil {
		log.Fatal(err)
	}
	logger, err = s.Logger(nil)
	if err != nil {
		log.Fatal(err)
	}
	err = s.Run()
	if err != nil {
		logger.Error(err)
	}

However, in 1.2.2 process B is labeled INTERACTIVE, which is incorrect.

Basically a process can be NON-INTERACTIVE, but not a WINDOWS SERVICE.
So the commit above is incorrect.

This is unfortunate. I'm not sure what the best solution is, though I recognize that this is a breaking change for you. I'll look into various implementations a bit more.