echo v3 quit speed is very slow in Windows OS Command Prompt

Created on 18 Nov 2016  路  18Comments  路  Source: labstack/echo

I deployed echo v3 from echo v2 in my project.
But if I press Ctrl+C in the windows command prompt, echo v3 is not exited immediately.
Only "echo:shutdown initiated", "echo: already shutting down" messages are showing.
After one min, echo was really exited then I can start server again.
What is wrong?

question

All 18 comments

echo exit speed

I pressed Ctrl+C for a long time. currently echo framework is not exited immediately.

It is because of the graceful shutdown library. Can you try to set shutdowntiomeout? Also check how graceful lib works on windows. I don't have windows to verify.

e := echo.New()
e.Use(middleware.Recover())
e.Use(middleware.CORS())
e.ShutdownTimeout = 3 * time.Second

I set shutdowntimeout like this, but it is not working...what am i wrong?

We use this library https://github.com/tylerb/graceful, can you try to run an example using it directly?

sir, i couldn't try graceful directly.
can you write down simple source to run graceful?
I am using websocket too.

e := echo.New()
... ...
e.GET("/ws", ws.HandleWebsocket)

// Start server
if err := e.Start(":" + config.Port); err != nil {
e.Logger.Fatal(err)
}
How can I run graceful directly?

Look at the project'' readme, you will find an example. The idea is the run it without Echo and see how it behaves.

I ran into this as well.

(For me) the problem was that the main goroutine was still running even after graceful had stopped the server. So before I had

func main() {
    go web()
    select {} // would block here after web goroutine finished after SIGINT
}

func web() {
    echo.StartServer(...)
}

Workaround was to do something like:

func main() {
    go web()
    <- exitCh
}

func web() {
    echo.StartServer(...)
    exitCh <- struct{}{}
}

HTH

Thanks a lot for your reply.
I have just checked your code. but it is not working. same issue
I am not rich experienced in golang. Can you post me full code.
I did like that

var exitCh = make(chan struct{})
// Run ...
func Run() {
go startServer()
<-exitCh
}

func startServer() {
e := echo.New()
... ...
... ...
// Start server
if err := e.Start(":8000"); err != nil {
e.Logger.Fatal(err)
}
exitCh <- struct{}{}
}
I am looking forward to hearing soon, Thanks,

Here is a working example:

package main

import (
    "log"

    "github.com/labstack/echo" // using master
)

func main() {
    ch := make(chan struct{})
    go listen(ch)
    <-ch
}

func listen(exitCh chan struct{}) {
    e := echo.New()
    if err := e.Start(":3232"); err != nil {
        log.Fatal(err)
    }
    exitCh <- struct{}{}
}

If you commented out the channel send, it would end up with the "already shutting down" problem:

// exitCh <- struct{}{}

As long as the goroutine with the main function exits, the process should stop.

same issue.
I have just run example source. not resolve issue.

untitled
I installed windows os 2 times to resolve this issue. Mac and Linux is working fine.
Previous os was win 8, current os is win 10.
Golang 1.7.3

Not sure dude. I just tried it on two Windows machines and it worked fine.

Do you have the latest version of echo and the graceful dependency? go get -u github.com/labstack/echo.

I have built the above program as a binary if you wanna try it - https://id-rsa.pub/graceful.exe

same issue
untitled

Sorry, absolutely no idea. I think you have something stinking up your environment. Anti-virus? Software firewall? Good luck :.

Thanks for your efforts.

One more, I have just checked other 2 window machines. But not working. :'(
very strange issue.

Mr, Vishr
Please resolve this issue asap, Actually there is not problem in the echo running.
But it is strange to develop the project.
Best Regards,

@TianDaGe I am not sure about the issue and I don't have windows to test. Looking at the comments, issue seems to be with the windows setup else it should be reproducible by all users. Closing for now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mmindenhall picture mmindenhall  路  4Comments

neutronstein picture neutronstein  路  3Comments

vishr picture vishr  路  3Comments

asdine picture asdine  路  3Comments

younisshah picture younisshah  路  4Comments