Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
c92d719a
Commit
c92d719a
authored
Apr 27, 2017
by
Mitja Z
Committed by
Torkel Ödegaard
Apr 27, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added support for listening on unix socket #4030 (#8221)
parent
d4f7a2bc
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
3 deletions
+28
-3
conf/defaults.ini
+4
-1
conf/sample.ini
+4
-1
pkg/api/http_server.go
+14
-1
pkg/setting/setting.go
+6
-0
No files found.
conf/defaults.ini
View file @
c92d719a
...
...
@@ -25,7 +25,7 @@ plugins = data/plugins
#################################### Server ##############################
[server]
# Protocol (http
or https
)
# Protocol (http
, https, socket
)
protocol
=
http
# The ip address to bind to, empty will bind to all interfaces
...
...
@@ -57,6 +57,9 @@ enable_gzip = false
cert_file
=
cert_key
=
# Unix socket path
socket
=
/tmp/grafana.sock
#################################### Database ############################
[database]
# You can configure the database connection by specifying type, host, name, user and password
...
...
conf/sample.ini
View file @
c92d719a
...
...
@@ -26,7 +26,7 @@
#
#################################### Server ####################################
[server]
# Protocol (http
or https
)
# Protocol (http
, https, socket
)
;protocol = http
# The ip address to bind to, empty will bind to all interfaces
...
...
@@ -59,6 +59,9 @@
;cert_file =
;cert_key =
# Unix socket path
;socket =
#################################### Database ####################################
[database]
# You can configure the database connection by specifying type, host, name, user and password
...
...
pkg/api/http_server.go
View file @
c92d719a
...
...
@@ -5,6 +5,7 @@ import (
"crypto/tls"
"errors"
"fmt"
"net"
"net/http"
"os"
"path"
...
...
@@ -49,7 +50,7 @@ func (hs *HttpServer) Start(ctx context.Context) error {
hs
.
streamManager
.
Run
(
ctx
)
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
}
switch
setting
.
Protocol
{
...
...
@@ -65,6 +66,18 @@ func (hs *HttpServer) Start(ctx context.Context) error {
hs
.
log
.
Debug
(
"server was shutdown gracefully"
)
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
:
hs
.
log
.
Error
(
"Invalid protocol"
,
"protocol"
,
setting
.
Protocol
)
err
=
errors
.
New
(
"Invalid Protocol"
)
...
...
pkg/setting/setting.go
View file @
c92d719a
...
...
@@ -27,6 +27,7 @@ type Scheme string
const
(
HTTP
Scheme
=
"http"
HTTPS
Scheme
=
"https"
SOCKET
Scheme
=
"socket"
DEFAULT_HTTP_ADDR
string
=
"0.0.0.0"
)
...
...
@@ -65,6 +66,7 @@ var (
HttpAddr
,
HttpPort
string
SshPort
int
CertFile
,
KeyFile
string
SocketPath
string
RouterLogging
bool
DataProxyLogging
bool
StaticRootPath
string
...
...
@@ -473,6 +475,10 @@ func NewConfigContext(args *CommandLineArgs) error {
CertFile
=
server
.
Key
(
"cert_file"
)
.
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"
)
HttpAddr
=
server
.
Key
(
"http_addr"
)
.
MustString
(
DEFAULT_HTTP_ADDR
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment