mirror of
https://github.com/gotify/server.git
synced 2024-01-28 15:20:56 +03:00
With this you can configure a unix socket in server.listenaddr and server.ssl.listenaddr by prefixing the socket path with unix: Co-authored-by: Jannis Mattheis <contact@jmattheis.de>
59 lines
1.3 KiB
Go
59 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"math/rand"
|
|
"os"
|
|
"time"
|
|
|
|
"github.com/gotify/server/v2/config"
|
|
"github.com/gotify/server/v2/database"
|
|
"github.com/gotify/server/v2/mode"
|
|
"github.com/gotify/server/v2/model"
|
|
"github.com/gotify/server/v2/router"
|
|
"github.com/gotify/server/v2/runner"
|
|
)
|
|
|
|
var (
|
|
// Version the version of Gotify.
|
|
Version = "unknown"
|
|
// Commit the git commit hash of this version.
|
|
Commit = "unknown"
|
|
// BuildDate the date on which this binary was build.
|
|
BuildDate = "unknown"
|
|
// Mode the build mode.
|
|
Mode = mode.Dev
|
|
)
|
|
|
|
func main() {
|
|
vInfo := &model.VersionInfo{Version: Version, Commit: Commit, BuildDate: BuildDate}
|
|
mode.Set(Mode)
|
|
|
|
fmt.Println("Starting Gotify version", vInfo.Version+"@"+BuildDate)
|
|
rand.Seed(time.Now().UnixNano())
|
|
conf := config.Get()
|
|
|
|
if conf.PluginsDir != "" {
|
|
if err := os.MkdirAll(conf.PluginsDir, 0o755); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
if err := os.MkdirAll(conf.UploadedImagesDir, 0o755); err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
db, err := database.New(conf.Database.Dialect, conf.Database.Connection, conf.DefaultUser.Name, conf.DefaultUser.Pass, conf.PassStrength, true)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
defer db.Close()
|
|
|
|
engine, closeable := router.Create(db, vInfo, conf)
|
|
defer closeable()
|
|
|
|
if err := runner.Run(engine, conf); err != nil {
|
|
fmt.Println("Server error: ", err)
|
|
os.Exit(1)
|
|
}
|
|
}
|