-
Notifications
You must be signed in to change notification settings - Fork 25
/
system.go
52 lines (44 loc) · 1.01 KB
/
system.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
49
50
51
52
/*
Copyright (C) CESS. All rights reserved.
Copyright (C) Cumulus Encrypted Storage System. All rights reserved.
SPDX-License-Identifier: Apache-2.0
*/
package configs
import (
"os"
"runtime"
"github.com/CESSProject/p2p-go/out"
)
const (
// Name is the name of the program
Name = "bucket"
// version
Version = "v0.7.7"
// Description is the description of the program
Description = "Storage node implementation in CESS networks"
// NameSpace is the cached namespace
NameSpaces = Name
// Chain version
ChainVersion = "0.7.5"
)
// system init
func SysInit(cpus uint8) int {
if !RunOnLinuxSystem() {
out.Err("Please run on a linux system")
os.Exit(1)
}
return SetCpuNumber(cpus)
}
func SetCpuNumber(cpus uint8) int {
actualUseCpus := runtime.NumCPU()
if cpus == 0 || int(cpus) > actualUseCpus {
runtime.GOMAXPROCS(actualUseCpus)
return actualUseCpus
}
actualUseCpus = int(cpus)
runtime.GOMAXPROCS(actualUseCpus)
return actualUseCpus
}
func RunOnLinuxSystem() bool {
return runtime.GOOS == "linux"
}