-
Notifications
You must be signed in to change notification settings - Fork 13
/
queued.go
46 lines (34 loc) · 1.12 KB
/
queued.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
package main
import (
"flag"
"fmt"
"github.com/scttnlsn/queued/queued"
"os"
"runtime"
)
var config *queued.Config
func init() {
config = queued.NewConfig()
flag.UintVar(&config.Port, "port", 5353, "port on which to listen")
flag.StringVar(&config.Auth, "auth", "", "HTTP basic auth password required for all requests")
flag.StringVar(&config.Store, "store", "leveldb", "the backend in which items will be stored (leveldb or memory)")
flag.StringVar(&config.DbPath, "db-path", "./queued.db", "the directory in which queue items will be persisted (n/a for memory store)")
flag.BoolVar(&config.Sync, "sync", true, "boolean indicating whether data should be synced to disk after every write (n/a for memory store)")
}
func main() {
version := flag.Bool("v", false, "output the version number")
flag.Parse()
if *version {
fmt.Println(queued.Version)
os.Exit(0)
}
runtime.GOMAXPROCS(runtime.NumCPU())
s := queued.NewServer(config)
err := s.ListenAndServe()
if err != nil {
panic(fmt.Sprintf("main: %v", err))
}
fmt.Printf("Listening on http://localhost%s\n", s.Addr)
shutdown := make(chan bool)
<-shutdown
}