-
Notifications
You must be signed in to change notification settings - Fork 4
/
state.go
34 lines (28 loc) · 1016 Bytes
/
state.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
// Content managed by Project Forge, see [projectforge.md] for details.
package cmd
import (
"context"
"github.com/pkg/errors"
"projectforge.dev/projectforge/app"
"projectforge.dev/projectforge/app/lib/filesystem"
"projectforge.dev/projectforge/app/lib/telemetry"
"projectforge.dev/projectforge/app/util"
)
func buildDefaultAppState(flags *Flags, logger util.Logger) (*app.State, error) {
fs := filesystem.NewFileSystem(flags.ConfigDir)
telemetryDisabled := util.GetEnvBool("disable_telemetry", false)
st, err := app.NewState(flags.Debug, _buildInfo, fs, !telemetryDisabled, flags.Port, logger)
if err != nil {
return nil, err
}
ctx, span, logger := telemetry.StartSpan(context.Background(), "app:init", logger)
defer span.Complete()
t := util.TimerStart()
svcs, err := app.NewServices(ctx, st, logger)
if err != nil {
return nil, errors.Wrap(err, "error creating services")
}
logger.Debugf("created app state in [%s]", util.MicrosToMillis(t.End()))
st.Services = svcs
return st, nil
}