+4
-1
@@ -25,7 +25,7 @@ plugins = data/plugins
|
|||||||
|
|
||||||
#################################### Server ##############################
|
#################################### Server ##############################
|
||||||
[server]
|
[server]
|
||||||
# Protocol (http or https)
|
# Protocol (http, https, socket)
|
||||||
protocol = http
|
protocol = http
|
||||||
|
|
||||||
# The ip address to bind to, empty will bind to all interfaces
|
# The ip address to bind to, empty will bind to all interfaces
|
||||||
@@ -57,6 +57,9 @@ enable_gzip = false
|
|||||||
cert_file =
|
cert_file =
|
||||||
cert_key =
|
cert_key =
|
||||||
|
|
||||||
|
# Unix socket path
|
||||||
|
socket = /tmp/grafana.sock
|
||||||
|
|
||||||
#################################### Database ############################
|
#################################### Database ############################
|
||||||
[database]
|
[database]
|
||||||
# You can configure the database connection by specifying type, host, name, user and password
|
# You can configure the database connection by specifying type, host, name, user and password
|
||||||
|
|||||||
+4
-1
@@ -26,7 +26,7 @@
|
|||||||
#
|
#
|
||||||
#################################### Server ####################################
|
#################################### Server ####################################
|
||||||
[server]
|
[server]
|
||||||
# Protocol (http or https)
|
# Protocol (http, https, socket)
|
||||||
;protocol = http
|
;protocol = http
|
||||||
|
|
||||||
# The ip address to bind to, empty will bind to all interfaces
|
# The ip address to bind to, empty will bind to all interfaces
|
||||||
@@ -59,6 +59,9 @@
|
|||||||
;cert_file =
|
;cert_file =
|
||||||
;cert_key =
|
;cert_key =
|
||||||
|
|
||||||
|
# Unix socket path
|
||||||
|
;socket =
|
||||||
|
|
||||||
#################################### Database ####################################
|
#################################### Database ####################################
|
||||||
[database]
|
[database]
|
||||||
# You can configure the database connection by specifying type, host, name, user and password
|
# You can configure the database connection by specifying type, host, name, user and password
|
||||||
|
|||||||
+14
-1
@@ -5,6 +5,7 @@ import (
|
|||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
@@ -49,7 +50,7 @@ func (hs *HttpServer) Start(ctx context.Context) error {
|
|||||||
hs.streamManager.Run(ctx)
|
hs.streamManager.Run(ctx)
|
||||||
|
|
||||||
listenAddr := fmt.Sprintf("%s:%s", setting.HttpAddr, setting.HttpPort)
|
listenAddr := fmt.Sprintf("%s:%s", setting.HttpAddr, setting.HttpPort)
|
||||||
hs.log.Info("Initializing HTTP Server", "address", listenAddr, "protocol", setting.Protocol, "subUrl", setting.AppSubUrl)
|
hs.log.Info("Initializing HTTP Server", "address", listenAddr, "protocol", setting.Protocol, "subUrl", setting.AppSubUrl, "socket", setting.SocketPath)
|
||||||
|
|
||||||
hs.httpSrv = &http.Server{Addr: listenAddr, Handler: hs.macaron}
|
hs.httpSrv = &http.Server{Addr: listenAddr, Handler: hs.macaron}
|
||||||
switch setting.Protocol {
|
switch setting.Protocol {
|
||||||
@@ -65,6 +66,18 @@ func (hs *HttpServer) Start(ctx context.Context) error {
|
|||||||
hs.log.Debug("server was shutdown gracefully")
|
hs.log.Debug("server was shutdown gracefully")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
case setting.SOCKET:
|
||||||
|
ln, err := net.Listen("unix", setting.SocketPath)
|
||||||
|
if err != nil {
|
||||||
|
hs.log.Debug("server was shutdown gracefully")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
err = hs.httpSrv.Serve(ln)
|
||||||
|
if err != nil {
|
||||||
|
hs.log.Debug("server was shutdown gracefully")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
hs.log.Error("Invalid protocol", "protocol", setting.Protocol)
|
hs.log.Error("Invalid protocol", "protocol", setting.Protocol)
|
||||||
err = errors.New("Invalid Protocol")
|
err = errors.New("Invalid Protocol")
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ type Scheme string
|
|||||||
const (
|
const (
|
||||||
HTTP Scheme = "http"
|
HTTP Scheme = "http"
|
||||||
HTTPS Scheme = "https"
|
HTTPS Scheme = "https"
|
||||||
|
SOCKET Scheme = "socket"
|
||||||
DEFAULT_HTTP_ADDR string = "0.0.0.0"
|
DEFAULT_HTTP_ADDR string = "0.0.0.0"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -65,6 +66,7 @@ var (
|
|||||||
HttpAddr, HttpPort string
|
HttpAddr, HttpPort string
|
||||||
SshPort int
|
SshPort int
|
||||||
CertFile, KeyFile string
|
CertFile, KeyFile string
|
||||||
|
SocketPath string
|
||||||
RouterLogging bool
|
RouterLogging bool
|
||||||
DataProxyLogging bool
|
DataProxyLogging bool
|
||||||
StaticRootPath string
|
StaticRootPath string
|
||||||
@@ -473,6 +475,10 @@ func NewConfigContext(args *CommandLineArgs) error {
|
|||||||
CertFile = server.Key("cert_file").String()
|
CertFile = server.Key("cert_file").String()
|
||||||
KeyFile = server.Key("cert_key").String()
|
KeyFile = server.Key("cert_key").String()
|
||||||
}
|
}
|
||||||
|
if server.Key("protocol").MustString("http") == "socket" {
|
||||||
|
Protocol = SOCKET
|
||||||
|
SocketPath = server.Key("socket").String()
|
||||||
|
}
|
||||||
|
|
||||||
Domain = server.Key("domain").MustString("localhost")
|
Domain = server.Key("domain").MustString("localhost")
|
||||||
HttpAddr = server.Key("http_addr").MustString(DEFAULT_HTTP_ADDR)
|
HttpAddr = server.Key("http_addr").MustString(DEFAULT_HTTP_ADDR)
|
||||||
|
|||||||
Reference in New Issue
Block a user