Comments (4)
I think it really doesn't work.
When the main goroutine exit, all the process will exit. It remains no chance to execute the sub goroutine's shutdown, right ?
Maybe we can change the code like:
package main
import (
"context"
"log"
"net/http"
"os/signal"
"syscall"
"time"
)
func main() {
ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGTERM, syscall.SIGINT)
http.HandleFunc("/ping", ping)
server := &http.Server{Addr: ":6666", Handler: nil}
go func() {
if err := server.ListenAndServe(); err != nil {
log.Printf("Failed to start http server, error: %s", err)
return
}
}()
<-ctx.Done()
// do some cleanup things
t, _ := context.WithTimeout(context.Background(), 5*time.Second)
if err := server.Shutdown(t); err != nil {
log.Printf("Failed to stop server, error: %s", err)
}
}
func ping(w http.ResponseWriter, r *http.Request) {
time.Sleep(4 * time.Second)
_, _ = w.Write([]byte("success"))
}
from zadig.
@KevinWu0904 Yes, yours is right !
from zadig.
@nanzm thank you for pointing out this, @KevinWu0904 thank you for your solution. It will appear in opensource version soon
from zadig.
fixed in #46
from zadig.
Related Issues (20)
- [bug]docker build stucked very frenquently HOT 1
- Failed to run: failed to login docker registry HOT 1
- 这个是什么原因 我应该怎么操作。 HOT 1
- [feature] The only variable types constructed are enumerations and strings. We need a data type that can be selected from multiple sources, such as named list. HOT 1
- maven构建错误[bug] HOT 1
- 配置完成后zadig选择 "代码库名称"显示为空 HOT 2
- [bug]垂直越权漏洞 + 信息泄露漏洞 + 逻辑漏洞 HOT 1
- [Question] 2.1版本安装问题,安装成功之后无法访问,aslan Pod 内无法访问自己
- The helm project was deleted inexplicably, causing deployment to fail. HOT 2
- Zadig是如何实现不同版本kubernetes API版本下的兼容 HOT 1
- [Question] Zadig gitlab代码库名称问题,授权成功之后无法选择默认分支,报错404 HOT 1
- [bug]]Cannot find docker host: no docker host found HOT 1
- [installation] 安装配置Mysql时显示结构反序列化类型错误 ConfigMap: json: cannot unmarshal number HOT 1
- [bug] miss makezero in slice init HOT 1
- 500 : Internal Error: mongo: no documents in result
- [Question] curl: (28) Resolving timed out after 10000 milliseconds
- [feature] support the multi-branch mode when building
- All in One 安装后,无法通过node IP+port访问 HOT 13
- default-registry-secret not created
- Proposal: add API based end-to-end (aka e2e) testing
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zadig.