main.go 653 Bytes
Newer Older
Lukas Böhm's avatar
Lukas Böhm committed
1
2
package main

Lukas Böhm's avatar
Lukas Böhm committed
3
4
5
import (
	"encoding/json"
	"fmt"
Lukas Böhm's avatar
Lukas Böhm committed
6
	"log"
Lukas Böhm's avatar
Lukas Böhm committed
7
	"os"
Lukas Böhm's avatar
Lukas Böhm committed
8
)
Lukas Böhm's avatar
Lukas Böhm committed
9

Lukas Böhm's avatar
Lukas Böhm committed
10
var config = struct {
Lukas Böhm's avatar
Lukas Böhm committed
11
12
	port      int
	mediaDir  string
Lukas Böhm's avatar
Lukas Böhm committed
13
	chunkSize int64
Lukas Böhm's avatar
Lukas Böhm committed
14
}{
Lukas Böhm's avatar
Lukas Böhm committed
15
16
17
	port:      6969,
	mediaDir:  os.Getenv("MEDIA_DIR"),
	chunkSize: 10 << 20, // 10 MB
Lukas Böhm's avatar
Lukas Böhm committed
18
19
}

Lukas Böhm's avatar
Lukas Böhm committed
20
func main() {
Lukas Böhm's avatar
Lukas Böhm committed
21
	// test database connection
Lukas Böhm's avatar
Lukas Böhm committed
22
23
24
25
	db, err := GetDatabase()
	if err != nil {
		log.Fatal("Cannot connect database")
	}
Lukas Böhm's avatar
Lukas Böhm committed
26
27
	// Migrate the schema
	db.AutoMigrate(&Share{})
Lukas Böhm's avatar
Lukas Böhm committed
28
	db.AutoMigrate(&Attachment{})
Lukas Böhm's avatar
Lukas Böhm committed
29
	// start
Lukas Böhm's avatar
Lukas Böhm committed
30
	fmt.Println("Let's go!!!")
Lukas Böhm's avatar
Lukas Böhm committed
31
	ConfigureRoutes()
Lukas Böhm's avatar
Lukas Böhm committed
32
	ConfigurePool()
Lukas Böhm's avatar
Lukas Böhm committed
33
}
Lukas Böhm's avatar
Lukas Böhm committed
34
35
36
37
38
39

func PrettyPrint(i interface{}) {
	b, err := json.MarshalIndent(i, "", "  ")
	if err != nil {
		fmt.Println(err)
	}
Lukas Böhm's avatar
Lukas Böhm committed
40
	fmt.Println(string(b))
Lukas Böhm's avatar
Lukas Böhm committed
41
}