المشاريع
عرض على GitHub
tabalt/gracehttp
حول
خادم HTTP بسيط وأنيق لـ Golang
الأنظمة والبنية التحتيةالنمو المقاس للنجوم
- خلال 24 ساعة
- ٠
- خلال 7 أيام
- ٠
- خلال 15 يومًا
- ٠
- خلال شهر
- جارٍ جمع السجل
تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.
README.md
الأصلgracehttp
This is a simple and graceful HTTP server for Golang.
Version
V1.2.0 (Require Go 1.8+)
Usage
package main
import (
"fmt"
"net/http"
"github.com/tabalt/gracehttp"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "hello world")
})
err := gracehttp.ListenAndServe(":8080", nil)
if err != nil {
fmt.Println(err)
}
}
Demo
Install the demo application
go get github.com/tabalt/gracehttp/gracehttpdemoStart it in the first terminal
gracehttpdemoThis will output something like:
2015/09/14 20:01:08 Serving :8080 with pid 4388.In a second terminal start a slow HTTP request
curl 'http://localhost:8080/sleep/?duration=20s'In a third terminal trigger a graceful server restart (using the pid from your output):
kill -SIGUSR2 $pidTrigger another shorter request that finishes before the earlier request:
curl 'http://localhost:8080/sleep/?duration=0s'
استكشف مشاريع مشابهة ومرتبطة
جارٍ التحميل…