-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.go
More file actions
42 lines (32 loc) · 829 Bytes
/
main.go
File metadata and controls
42 lines (32 loc) · 829 Bytes
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
package main
import (
"fmt"
"log"
"os"
"github.com/fluidkeys/api/cmd"
"github.com/fluidkeys/api/datastore"
"github.com/fluidkeys/api/server"
)
func main() {
err := datastore.Initialize(datastore.MustReadDatabaseURL())
if err != nil {
log.Printf("error from ListenAndServe: %v", err)
panic(err)
}
if len(os.Args) == 1 {
os.Exit(server.Serve())
} else if os.Args[1] == "migrate" {
os.Exit(cmd.Migrate())
} else if os.Args[1] == "print_expired_keys" {
os.Exit(cmd.PrintExpiredKeys())
} else if os.Args[1] == "delete_expired_keys" {
os.Exit(cmd.DeleteExpiredKeys())
} else if os.Args[1] == "send_emails" {
os.Exit(cmd.SendEmails())
} else if os.Args[1] == "send_test_emails" {
os.Exit(cmd.SendTestEmails())
} else {
fmt.Printf("unrecognised command: `%s`\n", os.Args[1])
os.Exit(1)
}
}