-
Notifications
You must be signed in to change notification settings - Fork 25
/
bundles.go
39 lines (30 loc) · 831 Bytes
/
bundles.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
import (
"fmt"
"io/ioutil"
"github.com/kentonh/gPanel/pkg/api/bundle"
"github.com/kentonh/gPanel/pkg/gpaccount"
)
func (con *Controller) detectBundles() error {
var err error = nil
bundles := make(map[string]*gpaccount.Controller)
dirs, err := ioutil.ReadDir("bundles/")
if err != nil {
fmt.Errorf("error finding bundles:%v", err.Error())
}
for _, dir := range dirs {
if dir.IsDir() {
dirPath := "bundles/" + dir.Name() + "/"
err, accPort, pubPort := bundle.GetPorts(dirPath)
curBundle, err := gpaccount.New(dirPath, dir.Name(), accPort, pubPort)
err = curBundle.Start()
err2 := curBundle.Public.Start()
if err != nil || err2 != nil {
fmt.Println("error starting bundle:", dir.Name())
}
bundles[dir.Name()] = curBundle
}
}
con.Bundles = bundles
return err
}