-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprocess.go
48 lines (39 loc) · 1.03 KB
/
process.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
package main
import (
"context"
"errors"
"io/ioutil"
"path/filepath"
goRuntime "runtime"
"strings"
"github.com/logrusorgru/aurora" // colorable
"go-micro.dev/v4/util/log"
"gopkg.in/yaml.v3"
"github.com/micro-community/stream/app"
"github.com/micro-community/stream/runtime"
)
// Run process
func Run(ctx context.Context, configFile string) (err error) {
_, enginePath, _, _ := goRuntime.Caller(0)
if parts := strings.Split(filepath.Dir(enginePath), "@"); len(parts) > 1 {
app.Version = parts[len(parts)-1]
}
rawConfigData, err := ioutil.ReadFile(configFile)
if err != nil {
log.Info(aurora.Red("read config file error:"), err)
return errors.New("read config file error")
}
//get config
var conf app.Configuration
if err := yaml.Unmarshal(rawConfigData, &conf); err != nil {
log.Error("parsing yml files error:,system will use default", err)
}
log.Info(aurora.Green("start stream server"), aurora.BrightBlue(app.Version))
go runtime.Summary.StartSummary()
for {
select {
case <-ctx.Done():
return
}
}
}