-
Notifications
You must be signed in to change notification settings - Fork 0
3.フロントエンド 1.unix_domain_socket
Kosugiyama edited this page Oct 30, 2015
·
1 revision
次のように変更する。
- log.Fatal(http.ListenAndServe(":8080", r))
+
+ s := "/dev/shm/app.sock"
+ os.Remove(s)
+ ll, err := net.Listen("unix", s)
+ if err != nil {
+ fmt.Println("%s\n", err);
+ return
+ }
+ os.Chmod(s, 0777)
+
+ sigc := make(chan os.Signal, 1);
+ signal.Notify(sigc, os.Interrupt, os.Kill, syscall.SIGTERM)
+ go func(c chan os.Signal){
+ sig := <-c
+ log.Printf("Caught signal %s: shutting down", sig)
+ ll.Close()
+ os.Exit(0)
+ }(sigc)
+
+ err = http.Serve(ll, r)
+ if err != nil {
+ panic(err)
+ }
}
nginx.conf
にも変更が必要。