Config: Improve docs and tests for Unix socket support #2337 #3595

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer 2023-08-16 10:14:19 +02:00
parent 91cc358fc5
commit 5b4b57e3bf
3 changed files with 19 additions and 39 deletions

View file

@ -8,15 +8,7 @@ import (
"github.com/photoprism/photoprism/internal/ttl"
)
func TestConfig_HttpSocket(t *testing.T) {
c := NewConfig(CliTestContext())
assert.Equal(t, "", c.HttpSocket())
c.options.HttpHost = "unix:/tmp/photoprism.sock"
assert.Equal(t, "/tmp/photoprism.sock", c.HttpSocket())
}
func TestConfig_HttpServerHost2(t *testing.T) {
func TestConfig_HttpServerHost(t *testing.T) {
c := NewConfig(CliTestContext())
assert.Equal(t, "0.0.0.0", c.HttpHost())
@ -26,15 +18,23 @@ func TestConfig_HttpServerHost2(t *testing.T) {
assert.Equal(t, "unix:/tmp/photoprism.sock", c.HttpHost())
}
func TestConfig_HttpServerPort2(t *testing.T) {
func TestConfig_HttpSocket(t *testing.T) {
c := NewConfig(CliTestContext())
assert.Equal(t, int(2342), c.HttpPort())
c.options.HttpPort = int(1234)
assert.Equal(t, int(1234), c.HttpPort())
assert.Equal(t, "", c.HttpSocket())
c.options.HttpHost = "unix:/tmp/photoprism.sock"
assert.Equal(t, "/tmp/photoprism.sock", c.HttpSocket())
}
func TestConfig_HttpServerMode2(t *testing.T) {
func TestConfig_HttpServerPort(t *testing.T) {
c := NewConfig(CliTestContext())
assert.Equal(t, 2342, c.HttpPort())
c.options.HttpPort = 1234
assert.Equal(t, 1234, c.HttpPort())
}
func TestConfig_HttpServerMode(t *testing.T) {
c := NewConfig(CliTestContext())
assert.Equal(t, HttpModeProd, c.HttpMode())

View file

@ -156,27 +156,6 @@ func TestConfig_DetachServer(t *testing.T) {
assert.Equal(t, false, detachServer)
}
func TestConfig_HttpServerHost(t *testing.T) {
c := NewConfig(CliTestContext())
host := c.HttpHost()
assert.Equal(t, "0.0.0.0", host)
}
func TestConfig_HttpServerPort(t *testing.T) {
c := NewConfig(CliTestContext())
port := c.HttpPort()
assert.Equal(t, 2342, port)
}
func TestConfig_HttpServerMode(t *testing.T) {
c := NewConfig(CliTestContext())
mode := c.HttpMode()
assert.Equal(t, HttpModeProd, mode)
}
func TestConfig_OriginalsPath(t *testing.T) {
c := NewConfig(CliTestContext())

View file

@ -473,12 +473,12 @@ var Flags = CliFlags{
}}, {
Flag: cli.StringFlag{
Name: "tls-cert",
Usage: "public HTTPS certificate `FILE` (.crt)",
Usage: "public HTTPS certificate `FILE` (.crt), ignored for Unix domain sockets",
EnvVar: EnvVar("TLS_CERT"),
}}, {
Flag: cli.StringFlag{
Name: "tls-key",
Usage: "private HTTPS key `FILE` (.key)",
Usage: "private HTTPS key `FILE` (.key), ignored for Unix domain sockets",
EnvVar: EnvVar("TLS_KEY"),
}}, {
Flag: cli.StringFlag{
@ -510,13 +510,14 @@ var Flags = CliFlags{
}}, {
Flag: cli.StringFlag{
Name: "http-host, ip",
Usage: "Web server `IP` address. If start with unix:, path followed is treated as unix socket path for listening.",
Value: "0.0.0.0",
Usage: "web server `IP` address or Unix domain socket, e.g. unix:/var/run/photoprism.sock",
EnvVar: EnvVar("HTTP_HOST"),
}}, {
Flag: cli.IntFlag{
Name: "http-port, port",
Value: 2342,
Usage: "Web server port `NUMBER`",
Usage: "web server port `NUMBER`, ignored for Unix domain sockets",
EnvVar: EnvVar("HTTP_PORT"),
}}, {
Flag: cli.StringFlag{