-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add configuration management and physical activity changes
- Loading branch information
Showing
17 changed files
with
159 additions
and
579 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[server] | ||
port = "9595" # define port number to run the service. It's your responsibility to select an unused port number. | ||
|
||
[files] | ||
guideline_file = "guideline_hearts.json" # name of the guideline JSON file | ||
guideline_content_file = "guideline_hearts_content.json" # name of the guideline content JSON file | ||
goal_file = "goals_hearts.json" # name of the goal JSON file | ||
goal_content_file = "goals_hearts_content.json" # name of the goal content JSON file | ||
log_file = "ohas-logs.db" # name of the logs database file | ||
|
||
[directories] | ||
guideline_path = "contents" # path of the directory for guideline JSON and guideline content JSON file | ||
goal_path = "contents" # path of the directory for goal JSON and goal content JSON file | ||
log_file_path = "~" # path of the log file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,58 @@ | ||
// Package config provides configuration constants and variables for the agent. | ||
// | ||
// WARNING: This package must not import any other agent's package. | ||
// Otherwide the circle dependency might occur. | ||
// Package config provides configuration constants and variables | ||
package config | ||
|
||
import ( | ||
"time" | ||
) | ||
|
||
// Default contains default configuration settings. | ||
var Default Settings = NewSettings() | ||
"path/filepath" | ||
|
||
// NewSettings returns default configuration settings. | ||
// | ||
// WARNING! All the configuration MUST be done by setting appropriate values here! | ||
func NewSettings() Settings { | ||
agent := &Agent{ | ||
// The number of tasks being executing simultaneously. | ||
maxTaskExecutors: 4, | ||
// An URL which is used when --local flag is passed. | ||
// Must not be changed. | ||
localServerURL: "http://127.0.0.1:8080", | ||
"github.com/spf13/viper" | ||
) | ||
|
||
// Interval between iterations. | ||
loopInterval: 60 * time.Second, | ||
startDelayDuration: 2 * time.Minute, | ||
// CurrentSettings function selects and responds correct settings | ||
func CurrentSettings() Settings { | ||
v := viper.New() | ||
defaults := defaultSettings() | ||
|
||
// Default Timeout for shell commands. | ||
// Must not be changed. | ||
cmdexecTimeout: 10 * time.Second, | ||
for key, value := range defaults { | ||
v.SetDefault(key, value) | ||
} | ||
|
||
api := &API{ | ||
Methods: map[string]string{ | ||
EPCompanyConfiguration: "/api/v2.1/company-configuration", | ||
EPConnections: "/api/v2.1/connections", | ||
EPFile: "/api/v2/file", | ||
EPFileSearch: "/api/v2/file-search", | ||
EPFileSystem: "/api/v2/filesystem-snapshot", | ||
EPLog: "/api/v2/log", | ||
EPRegister: "/api/v2/agent/register", | ||
EPReport: "/api/v2/report", | ||
}, | ||
} | ||
v.SetConfigName("ohas") | ||
v.AddConfigPath("/etc/ohas/") | ||
v.AddConfigPath("/usr/local/ohas/") | ||
v.AddConfigPath("/usr/local/etc/ohas/") | ||
v.AddConfigPath("/var/lib/ohas/") | ||
v.AddConfigPath(".") | ||
|
||
common := &Common{ | ||
appAuthorName: "CF Automation", | ||
appAuthorEmail: "ms.cf.automation@aurea.com", | ||
licenseKey: "unknown", | ||
serverURL: "https://gravity.devfactory.com", | ||
logDestination: "combined", | ||
logLevel: "info", | ||
logMaxFileSize: 10 * 1 << 20, | ||
v.ReadInConfig() | ||
|
||
// Daemon graceful timeout. | ||
gracefulTimeout: 15 * time.Second, | ||
connMapDuration: 10 * 60 * 60, | ||
} | ||
return configSettings(v) | ||
} | ||
|
||
http := &HTTP{ | ||
// This value sets actual timeout for http client. | ||
clientTimeout: 180 * time.Second, | ||
func defaultSettings() map[string]interface{} { | ||
settings := map[string]interface{}{ | ||
"server.port": "9595", | ||
"files.guideline_file": "guideline_hearts.json", | ||
"files.guideline_content_file": "guideline_hearts_content.json", | ||
"files.goal_file": "goals_hearts.json", | ||
"files.goal_content_file": "goals_hearts_content.json", | ||
"files.log_file": "logs.db", | ||
"directories.guideline_path": "", | ||
"directories.goal_path": "", | ||
"directories.log_file_path": "", | ||
} | ||
|
||
// Settings for retry in httplib.Service. | ||
backoffMinTimeout: 100 * time.Millisecond, | ||
backoffMaxTimeout: 5 * time.Minute, | ||
backoffFactor: 2, | ||
return settings | ||
} | ||
|
||
// Low level http transport settings. | ||
// They must not be changed at all. | ||
dialTimeout: 30 * time.Second, | ||
keepAlive: 30 * time.Second, | ||
tLSHandshakeTimeout: 10 * time.Second, | ||
idleConnTimeout: 90 * time.Second, | ||
expectContinueTimeout: 1 * time.Second, | ||
} | ||
func configSettings(v *viper.Viper) Settings { | ||
settings := Settings{} | ||
|
||
settings := Settings{ | ||
Agent: agent, | ||
API: api, | ||
Common: common, | ||
HTTP: http, | ||
Operations: operationsList, | ||
} | ||
settings.Port = v.GetString("server.port") | ||
settings.GuidelineFile = filepath.Join(v.GetString("directories.guideline_path"), v.GetString("files.guideline_file")) | ||
settings.GuidelineContentFile = filepath.Join(v.GetString("directories.guideline_path"), v.GetString("files.guideline_content_file")) | ||
settings.GoalFile = filepath.Join(v.GetString("directories.goal_path"), v.GetString("files.goal_file")) | ||
settings.GoalContentFile = filepath.Join(v.GetString("directories.goal_path"), v.GetString("files.goal_content_file")) | ||
settings.LogFile = filepath.Join(v.GetString("directories.log_file_path"), v.GetString("files.log_file")) | ||
|
||
return settings | ||
} |
Oops, something went wrong.