forked from boypt/simple-torrent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
51 lines (43 loc) · 831 Bytes
/
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
package main
import (
"errors"
"fmt"
"log"
"os"
"runtime"
"strconv"
"time"
"github.com/boypt/simple-torrent/server"
"github.com/jpillora/opts"
)
var VERSION = "0.0.0-src" //set with ldflags
func main() {
s := server.Server{
Title: "SimpleTorrent",
Port: 3000, // depreciated
Listen: ":3000",
}
o := opts.New(&s)
o.Version(VERSION)
o.Repo("https://github.com/boypt/simple-torrent")
o.PkgRepo()
o.SetLineWidth(96)
o.Parse()
t := &server.TPLInfo{
Title: s.Title,
Version: VERSION,
Runtime: fmt.Sprintf("%s %d bit", runtime.Version(), strconv.IntSize),
Uptime: time.Now().Unix(),
}
if s.DisableLogTime {
log.SetFlags(0)
}
log.Print(t.GetInfo())
if err := s.Run(t); err != nil {
if errors.Is(err, server.ErrDiskSpace) {
log.Println(err)
os.Exit(42)
}
log.Fatal(err)
}
}