58 lines
1.1 KiB
Go
58 lines
1.1 KiB
Go
package commands
|
|
|
|
import (
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
"github.com/photoprism/photoprism/internal/config"
|
|
"github.com/photoprism/photoprism/internal/server"
|
|
"github.com/urfave/cli"
|
|
)
|
|
|
|
// Starts web server (user interface)
|
|
var StartCommand = cli.Command{
|
|
Name: "start",
|
|
Usage: "Starts web server",
|
|
Flags: startFlags,
|
|
Action: startAction,
|
|
}
|
|
|
|
var startFlags = []cli.Flag{
|
|
cli.IntFlag{
|
|
Name: "http-port, p",
|
|
Usage: "HTTP server port",
|
|
Value: 80,
|
|
EnvVar: "PHOTOPRISM_HTTP_PORT",
|
|
},
|
|
cli.StringFlag{
|
|
Name: "http-host, i",
|
|
Usage: "HTTP server host",
|
|
Value: "",
|
|
EnvVar: "PHOTOPRISM_HTTP_HOST",
|
|
},
|
|
cli.StringFlag{
|
|
Name: "http-mode, m",
|
|
Usage: "debug, release or test",
|
|
Value: "",
|
|
EnvVar: "PHOTOPRISM_HTTP_MODE",
|
|
},
|
|
}
|
|
|
|
func startAction(ctx *cli.Context) error {
|
|
conf := config.NewConfig(ctx)
|
|
|
|
if conf.HttpServerPort() < 1 {
|
|
log.Fatal("server port must be a positive integer")
|
|
}
|
|
|
|
if err := conf.CreateDirectories(); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
conf.MigrateDb()
|
|
|
|
log.Infof("starting web server at %s:%d", conf.HttpServerHost(), conf.HttpServerPort())
|
|
|
|
server.Start(conf)
|
|
|
|
return nil
|
|
}
|