/
main.go
42 lines (32 loc) · 1.17 KB
/
main.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
// Copyright (C) 2020 Storj Labs, Inc.
// See LICENSE for copying information.
package main
import (
"os"
"go.uber.org/zap"
"storj.io/common/process"
_ "storj.io/storj/private/version" // This attaches version information during release builds.
"storj.io/storj/storagenode/pieces/lazyfilewalker"
_ "storj.io/storj/web/storagenode" // This embeds storagenode assets.
)
func main() {
process.SetHardcodedApplicationName("storagenode")
allowDefaults := !isFilewalkerCommand()
rootCmd, _ := newRootCmd(allowDefaults)
if startAsService(rootCmd) {
return
}
loggerFunc := func(logger *zap.Logger) *zap.Logger {
return logger.With(zap.String("process", rootCmd.Use))
}
process.ExecWithCustomOptions(rootCmd, process.ExecOptions{
InitDefaultDebugServer: allowDefaults,
InitTracing: allowDefaults,
InitProfiler: allowDefaults,
LoggerFactory: loggerFunc,
LoadConfig: process.LoadConfig,
})
}
func isFilewalkerCommand() bool {
return len(os.Args) > 1 && (os.Args[1] == lazyfilewalker.UsedSpaceFilewalkerCmdName || os.Args[1] == lazyfilewalker.GCFilewalkerCmdName || os.Args[1] == lazyfilewalker.TrashCleanupFilewalkerCmdName)
}