Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sys/windows/svc -> How To Create a Window Service Using Confluent-Kafka-Go #46800

Closed
Orlandoiii opened this issue Jun 17, 2021 · 1 comment
Closed

Comments

@Orlandoiii
Copy link

I have a service when I use golang.org/x/sys/windows/svc to create my api as window service. This works perfect.
I was able to follow this How to use Golang client on Windows #128 and thats work to. I can consume, produce my api work as I want. I can use both librerys and when I run the service in debug mode everything is fine. But when the api is a window service the service dont start I got a 1053 error message. I was running several test and I can say the service dont work when I use the confluent librery. I know that because this librery dont support window something is missing when .exe run as service but I can figure out what it is.

How to reproduce
I make a little program apart from my main project. Justo copy and paste the example from here golang.org/x/sys/windows/svc and add a consumer from confluent.
This what i have in the Excute function
const cmdsAccepted = svc.AcceptStop | svc.AcceptShutdown | svc.AcceptPauseAndContinue
changes <- svc.Status{State: svc.StartPending}

if _, err := os.Stat(".\LOGSmsPrueba"); os.IsNotExist(err) {
os.MkdirAll(".\LOGSmsPrueba", 0700)
}
filelogs, _ := os.OpenFile(".\LOGSmsPrueba\LOGS.log", os.O_APPEND|os.O_CREATE|os.O_RDWR, 0644)
//writerLog := zerolog.MultiLevelWriter(filelogs)
defer filelogs.Close()

log := zerolog.New(filelogs).With().Logger()
log.Debug().Msg("Before The Thread Of Consumer")
go func() {

log := zerolog.New(filelogs).With().Logger()

kafkaservice.ConsumidorKafka(&log)

}()

changes <- svc.Status{State: svc.Running, Accepts: cmdsAccepted}
loop:
for {
select {

case c := <-r:
	switch c.Cmd {
	case svc.Interrogate:
		changes <- c.CurrentStatus
		// Testing deadlock from https://code.google.com/p/winsvc/issues/detail?id=4
		time.Sleep(100 * time.Millisecond)
		changes <- c.CurrentStatus
	case svc.Stop, svc.Shutdown:
		// golang.org/x/sys/windows/svc.TestExample is verifying this output.
		testOutput := strings.Join(args, "-")
		testOutput += fmt.Sprintf("-%d", c.Context)
		elog.Info(1, testOutput)
		break loop
	case svc.Pause:
		changes <- svc.Status{State: svc.Paused, Accepts: cmdsAccepted}

	case svc.Continue:
		changes <- svc.Status{State: svc.Running, Accepts: cmdsAccepted}

	default:
		elog.Error(1, fmt.Sprintf("unexpected control request #%d", c))
	}
}

}
changes <- svc.Status{State: svc.StopPending}
return
Checklist

librdkafka Version: 1.7.0
confluent-kafka-go Version:1.7.0
&kafka.ConfigMap{
"bootstrap.servers": "localhost:9092",

"broker.address.family": "v4",
"group.id":              "grp.banco_emisor.credt_transf_inmdt",
"session.timeout.ms":    6000,
"auto.offset.reset":     "earliest"}

golang.org/x/sys v0.0.0-20210615035016

@seankhliao
Copy link
Member

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@golang golang locked and limited conversation to collaborators Jun 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants