...
1
18
19
20 package config
21
22 import (
23 "io/ioutil"
24 "scheduler/log"
25 "strings"
26 )
27
28 const AppName = "p2pfaas-scheduler"
29 const AppVersion = "0.3.0b"
30 const AppVersionCommit = "xxx"
31
32 const DataPath = "/data"
33
34
35 const ConfigurationFileName = "p2p_faas-scheduler.json"
36 const ConfigurationSchedulerFileName = "p2p_faas-scheduler-config.json"
37
38
39
40
41 const DefaultListeningPort = 18080
42 const DefaultQueueLengthMax = 100
43 const DefaultFunctionsRunningMax = 10
44 const DefaultRunningEnvironment = RunningEnvironmentProduction
45
46
47 const EnvRunningEnvironment = "P2PFAAS_DEV_ENV"
48 const EnvServiceDiscoveryListeningHost = "P2PFAAS_SERVICE_DISCOVERY_HOST"
49 const EnvServiceDiscoveryListeningPort = "P2PFAAS_SERVICE_DISCOVERY_PORT"
50 const EnvServiceLearningListeningHost = "P2PFAAS_SERVICE_LEARNING_HOST"
51 const EnvServiceLearningListeningPort = "P2PFAAS_SERVICE_LEARNING_PORT"
52 const EnvOpenFaasEnabled = "P2PFAAS_OPENFAAS_ENABLED"
53 const EnvOpenFaasListeningHost = "P2PFAAS_OPENFAAS_HOST"
54 const EnvOpenFaasListeningPort = "P2PFAAS_OPENFAAS_PORT"
55 const EnvFunctionsList = "P2PFAAS_FNS_LIST"
56 const EnvDataPath = "P2PFAAS_DATA_PATH"
57
58 const EnvProfiling = "P2PFAAS_PROF"
59
60 const DefaultServiceDiscoveryListeningHost = "discovery"
61 const DefaultServiceDiscoveryListeningPort = 19000
62
63 const DefaultServiceLearningListeningHost = "learner"
64 const DefaultServiceLearningListeningPort = 19020
65
66 const RunningEnvironmentProduction = "production"
67 const RunningEnvironmentDevelopment = "development"
68
69 const DefaultOpenFaaSListeningHost = "faas_containers-openfaas-swarm"
70 const DefaultOpenFaaSListeningPort = 8080
71
72 const DefaultDataPath = "/data"
73
74 const UserAgentMachine = "Machine"
75
76
79
80 var OpenFaaSUsername = "admin"
81 var OpenFaaSPassword = "admin"
82
83 var configurationStatic *ConfigurationStatic
84 var configurationDynamic *ConfigurationDynamic
85
86 var configurationDynamicReadFromFile = false
87
88 func init() {
89
90 InitConfigurationStatic()
91 InitConfigurationDynamic()
92
93
94
95 log.Log.Infof("Starting in %s environment", GetRunningEnvironment())
96
97 if GetOpenFaasEnabled() {
98 username, _ := ioutil.ReadFile("/run/secrets/basic-auth-user")
99 OpenFaaSUsername = strings.TrimSpace(string(username))
100 password, _ := ioutil.ReadFile("/run/secrets/basic-auth-password")
101 OpenFaaSPassword = strings.TrimSpace(string(password))
102 }
103
104
105
106
107 log.Log.Infof("Init with RunningFunctionsMax %d, QueueMaxLength %d, QueueEnabled %v",
108 GetRunningFunctionMax(), GetQueueLengthMax(), GetQueueEnabled())
109
110 }
111
112 func Start() {
113
114 }
115
View as plain text