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

gin run only works first time after reboot #143

Open
taoma opened this issue Aug 24, 2018 · 3 comments
Open

gin run only works first time after reboot #143

taoma opened this issue Aug 24, 2018 · 3 comments

Comments

@taoma
Copy link

taoma commented Aug 24, 2018

See the following console output.

$ gin run main.go
[gin] Listening on port 3000
[gin] Building...
[gin] Build finished
[DBUG] 2018/08/24 09:25 POST: /decode -> main.main.func1()
[DBUG] 2018/08/24 09:25 GET: /encode -> main.main.func2()
[DBUG] 2018/08/24 09:25 GET: /binary -> main.main.func3()
[DBUG] 2018/08/24 09:25 GET: /text -> main.main.func4()
[DBUG] 2018/08/24 09:25 GET: /json -> main.main.func5()
[DBUG] 2018/08/24 09:25 GET: /jsonp -> main.main.func6()
[DBUG] 2018/08/24 09:25 GET: /xml -> main.main.func7()
[DBUG] 2018/08/24 09:25 GET: /markdown -> main.main.func8()
[DBUG] 2018/08/24 09:25 Application: running using 1 host(s)
[DBUG] 2018/08/24 09:25 Host: addr is :8080
[DBUG] 2018/08/24 09:25 Host: virtual host is localhost:8080
[DBUG] 2018/08/24 09:25 Host: register startup notifier
[DBUG] 2018/08/24 09:25 Host: register server shutdown on interrupt(CTRL+C/CMD+C)
[DBUG] 2018/08/24 09:25 Host: server will ignore the following errors: [http: Server closed]
Now listening on: http://localhost:8080
Application started. Press CMD+C to shut down.
2018/08/24 09:25:49 http: proxy error: dial tcp [::1]:3001: connect: connection refused
2018/08/24 09:25:49 http: proxy error: dial tcp [::1]:3001: connect: connection refused
[gin] Building...
[gin] Build finished <-- after build, doesn't restart the host anymore. http://localhost:8080 gave 'This site can’t be reached' error
[gin] Building...
[gin] Build finished

@mnvx
Copy link

mnvx commented Oct 4, 2018

I has stucked with this problem too.

And it works after I open page in browser: http://localhost:3000

$ go version
go version go1.11.1 linux/amd64
$ gin -v
gin version 0.0.0

@mnvx
Copy link

mnvx commented Oct 4, 2018

Hmm.. I have found reason. Now I run command with -i flag:

$ gin -i run main.go

And it works well:

$ gin -i run main.go
[gin] Listening on port 3000
[gin] Building...
[gin] Build finished
[GIN-debug] [WARNING] Now Gin requires Go 1.6 or later and Go 1.7 will be required soon.

[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:	export GIN_MODE=release
 - using code:	gin.SetMode(gin.ReleaseMode)

[GIN-debug] GET    /ping                     --> main.setupRouter.func1 (3 handlers)
[GIN-debug] GET    /user/:name               --> main.setupRouter.func2 (3 handlers)
[GIN-debug] POST   /admin                    --> main.setupRouter.func3 (4 handlers)
[GIN-debug] Listening and serving HTTP on :8080
[GIN] 2018/10/04 - 15:54:04 | 200 |     135.256µs |             ::1 | GET      /user/test
[gin] Building...
[gin] Build finished
[GIN-debug] [WARNING] Now Gin requires Go 1.6 or later and Go 1.7 will be required soon.

[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:	export GIN_MODE=release
 - using code:	gin.SetMode(gin.ReleaseMode)

[GIN-debug] GET    /ping                     --> main.setupRouter.func1 (3 handlers)
[GIN-debug] GET    /user/:name               --> main.setupRouter.func2 (3 handlers)
[GIN-debug] POST   /admin                    --> main.setupRouter.func3 (4 handlers)
[GIN-debug] Listening and serving HTTP on :8080
[GIN] 2018/10/04 - 15:54:09 | 200 |      94.992µs |             ::1 | GET      /user/test

About this option:

--immediate, -i               run the server immediately after it's built

@wandercn
Copy link

hotbuild.ffactory.org you can try it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants