-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
52 lines (40 loc) · 1.57 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"fmt"
"log"
"os"
"github.com/jessevdk/go-flags"
"github.com/vdimir/markify/app"
)
var revision = "local"
// Opts contains command line options (see go-flags for details)
type Opts struct {
Hostname string `short:"h" long:"host" required:"false" description:"server host name" env:"MARKIFY_SERVER_HOSTNAME"`
Port uint16 `short:"p" long:"port" required:"false" description:"server port" env:"MARKIFY_SERVER_PORT" default:"8080"`
Storage string `short:"s" long:"storage" required:"false" description:"storage specification '<type_of_storage>:<config>', see storage code for details" env:"MARKIFY_STORAGE" default:"local:./"`
AdminPassword string `long:"admin_secret" required:"false" description:"Admin credential to access /_admin endpoint" env:"MARKIFY_ADMIN_PWD"`
SecretSeed string `long:"seed_secret" required:"false" description:"Secret seed to generate tokens" env:"MARKIFY_SEED"`
Debug bool `long:"debug" description:"debug mode"`
}
func main() {
log.Printf("[DEBUG] Starting app version %s\n", revision)
var opts Opts
_, err := flags.Parse(&opts)
if err != nil {
os.Exit(1)
}
appServer, err := app.NewApp(&app.Config{
Debug: opts.Debug,
AssetsPrefix: "app/assets",
StorageSpec: opts.Storage,
StatusText: fmt.Sprintf(`{"revision":"%s"}`, revision),
AdminPassword: opts.AdminPassword,
UIDSecret: opts.SecretSeed,
})
if err != nil {
log.Printf("[ERROR] App can't be created: %s", err)
panic(err)
}
appServer.StartServer(opts.Hostname, opts.Port)
log.Printf("[DEBUG] App closed")
}