You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// AppEngineDataDir is the relative path to a data directory that contains config files and data files required for launching laitos program
52
+
// on GCP app engine.
53
+
AppEngineDataDir="./gcp_appengine_data"
54
+
)
55
+
49
56
var (
50
57
// pprofHTTPPort is the localhost port to listen on for serving pprof profiling data over HTTP.
51
58
// The port number must differ from those used with regular HTTP and HTTPS servers.
@@ -126,15 +133,21 @@ func main() {
126
133
vargomaxprocsint
127
134
flag.StringVar(&misc.ConfigFilePath, launcher.ConfigFlagName, "", "(Mandatory) path to configuration file in JSON syntax")
128
135
flag.StringVar(&daemonList, launcher.DaemonsFlagName, "", "(Mandatory) comma-separated list of daemon names to start (autounlock, dnsd, httpd, httpproxy, insecurehttpd, maintenance, passwdrpc, phonehome, plainsocket, serialport, simpleipsvcd, smtpd, snmpd, sockd, telegram)")
129
-
flag.BoolVar(&disableConflicts, "disableconflicts", false, "(Optional) automatically stop and disable other daemon programs that may cause port usage conflicts")
130
136
flag.BoolVar(&awsLambda, launcher.LambdaFlagName, false, "(Optional) run AWS Lambda handler to proxy HTTP requests to laitos web server")
137
+
// Internal supervisor flag
138
+
varisSupervisor=true
139
+
flag.BoolVar(&isSupervisor, launcher.SupervisorFlagName, true, "(Internal use only) launch a supervisor process to auto-restart laitos main process in case of crash")
140
+
// Auxiliary features
141
+
flag.BoolVar(&disableConflicts, "disableconflicts", false, "(Optional) automatically stop and disable other daemon programs that may cause port usage conflicts")
142
+
flag.StringVar(&passwordUnlockServers, "passwordunlockservers", "", "(Optional) comma-separated list of server:port combos that offer password unlocking service (daemon \"passwdrpc\") over gRPC")
143
+
// Optional integration features
131
144
flag.BoolVar(&misc.EnableAWSIntegration, "awsinteg", false, "(Optional) activate all points of integration with various AWS services such as sending warning log entries to SQS")
132
145
flag.BoolVar(&misc.EnablePrometheusIntegration, "prominteg", false, "(Optional) activate all points of integration with Prometheus such as collecting performance metrics and serving them over HTTP")
flag.IntVar(&pprofHTTPPort, "profhttpport", pprofHTTPPort, "(Optional) serve program profiling data (pprof) over HTTP on this port at localhost")
135
149
flag.IntVar(&gomaxprocs, "gomaxprocs", 0, "(Optional) set gomaxprocs")
136
-
flag.StringVar(&passwordUnlockServers, "passwordunlockservers", "", "(Optional) comma-separated list of server:port combos that offer password unlocking service (daemon \"passwdrpc\") over gRPC")
flag.StringVar(&dataUtil, "datautil", "", "(Optional) program data encryption utility: encrypt|decrypt")
147
160
flag.StringVar(&dataUtilFile, "datautilfile", "", "(Optional) program data encryption utility: encrypt/decrypt file location")
148
-
// Internal supervisor flag
149
-
varisSupervisor=true
150
-
flag.BoolVar(&isSupervisor, launcher.SupervisorFlagName, true, "(Internal use only) launch a supervisor process to auto-restart laitos main process in case of crash")
151
161
152
162
flag.Parse()
153
163
164
+
logger.Info("main", "", nil, "program is starting, here is a summary of the runtime environment:\n%s", platform.GetProgramStatusSummary(false))
165
+
// FIXME: TODO: this main function is way too long >:-|
166
+
ifos.Getenv("GAE_ENV") =="standard" {
167
+
// Change working directory to the data directory (if not done yet).
168
+
// All program config files and data files are expected to reside in the data directory.
169
+
cwd, err:=os.Getwd()
170
+
iferr!=nil {
171
+
logger.Abort("main", "", err, "failed to determine current working directory")
172
+
}
173
+
ifpath.Base(cwd) !=path.Base(AppEngineDataDir) {
174
+
iferr:=os.Chdir(AppEngineDataDir); err!=nil {
175
+
logger.Abort("main", "", err, "failed to change directory to %s", AppEngineDataDir)
176
+
return
177
+
}
178
+
}
179
+
// Read the value of CLI parameter "-daemons" from a text file
0 commit comments