-
Notifications
You must be signed in to change notification settings - Fork 25
/
gpserver.go
39 lines (31 loc) · 826 Bytes
/
gpserver.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
// Package gpserver handles the logic of the gPanel server
package gpserver
import (
"log"
"os"
"github.com/kentonh/gPanel/pkg/gpaccount"
)
type Controller struct {
Directory string
DocumentRoot string
Bundles map[string]*gpaccount.Controller
ServerLogger *log.Logger
APILogger *log.Logger
}
func New() (*Controller, error) {
var err error = nil
f, err := os.OpenFile("server/logs/server_errors.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
log.Fatalf("error whilst trying to start server logging instance:%v", err.Error())
}
c := Controller{
Directory: "server/",
DocumentRoot: "document_root/",
Bundles: nil,
ServerLogger: log.New(f, "SERVER :: ", 3),
APILogger: log.New(f, "API :: ", 3),
}
err = c.detectBundles()
c.setDefaults()
return &c, err
}