diff --git a/cmd/run.go b/cmd/run.go index f664a7eef..8674061bb 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -547,6 +547,16 @@ func executeRun(runTemplateName, runFilePath string, apps []runfileconfig.App) ( // Update extended metadata with run file path. putRunTemplateNameInMeta(runState, runTemplateName) + // Update extended metadata with app log file path. + if app.AppLogDestination != standalone.Console { + putAppLogFilePathInMeta(runState, app.AppLogFileName) + } + + // Update extended metadata with daprd log file path. + if app.DaprdLogDestination != standalone.Console { + putDaprLogFilePathInMeta(runState, app.DaprdLogFileName) + } + if runState.AppCMD.Command != nil { putAppCommandInMeta(runConfig, runState) @@ -999,6 +1009,22 @@ func putRunTemplateNameInMeta(runE *runExec.RunExec, runTemplateName string) { } } +// putAppLogFilePathInMeta puts the absolute path of app log file in metadata so that it can be used by the CLI to stop the app. +func putAppLogFilePathInMeta(runE *runExec.RunExec, appLogFilePath string) { + err := metadata.Put(runE.DaprHTTPPort, "appLogPath", appLogFilePath, runE.AppID, unixDomainSocket) + if err != nil { + print.StatusEvent(runE.DaprCMD.OutputWriter, print.LogWarning, "Could not update sidecar metadata for app log file path: %s", err.Error()) + } +} + +// putDaprLogFilePathInMeta puts the absolute path of Dapr log file in metadata so that it can be used by the CLI to stop the app. +func putDaprLogFilePathInMeta(runE *runExec.RunExec, daprLogFilePath string) { + err := metadata.Put(runE.DaprHTTPPort, "daprdLogPath", daprLogFilePath, runE.AppID, unixDomainSocket) + if err != nil { + print.StatusEvent(runE.DaprCMD.OutputWriter, print.LogWarning, "Could not update sidecar metadata for dapr log file path: %s", err.Error()) + } +} + // getRunFilePath returns the path to the run file. // If the provided path is a path to a YAML file then return the same. // Else it returns the path of "dapr.yaml" in the provided directory. diff --git a/pkg/standalone/list.go b/pkg/standalone/list.go index 63a15fcec..342d67301 100644 --- a/pkg/standalone/list.go +++ b/pkg/standalone/list.go @@ -44,6 +44,8 @@ type ListOutput struct { MaxRequestBodySize int `csv:"-" json:"maxRequestBodySize" yaml:"maxRequestBodySize"` // Additional field, not displayed in table. HTTPReadBufferSize int `csv:"-" json:"httpReadBufferSize" yaml:"httpReadBufferSize"` // Additional field, not displayed in table. RunTemplatePath string `csv:"RUN_TEMPLATE_PATH" json:"runTemplatePath" yaml:"runTemplatePath"` + AppLogPath string `csv:"APP_LOG_PATH" json:"appLogPath" yaml:"appLogPath"` + DaprDLogPath string `csv:"DAPRD_LOG_PATH" json:"daprdLogPath" yaml:"daprdLogPath"` RunTemplateName string `json:"runTemplateName" yaml:"runTemplateName"` // specifically omitted in csv output. } @@ -112,6 +114,8 @@ func List() ([]ListOutput, error) { appPIDString := "" cliPIDString := "" runTemplatePath := "" + appLogPath := "" + daprdLogPath := "" runTemplateName := "" socket := argumentsMap["--unix-domain-socket"] appMetadata, err := metadata.Get(httpPort, appID, socket) @@ -121,6 +125,8 @@ func List() ([]ListOutput, error) { cliPIDString = appMetadata.Extended["cliPID"] runTemplatePath = appMetadata.Extended["runTemplatePath"] runTemplateName = appMetadata.Extended["runTemplateName"] + appLogPath = appMetadata.Extended["appLogPath"] + daprdLogPath = appMetadata.Extended["daprdLogPath"] } appPID, err := strconv.Atoi(appPIDString) @@ -159,6 +165,8 @@ func List() ([]ListOutput, error) { HTTPReadBufferSize: httpReadBufferSize, RunTemplatePath: runTemplatePath, RunTemplateName: runTemplateName, + AppLogPath: appLogPath, + DaprDLogPath: daprdLogPath, } // filter only dashboard instance. diff --git a/tests/e2e/standalone/list_test.go b/tests/e2e/standalone/list_test.go index 2071dad17..a33345644 100644 --- a/tests/e2e/standalone/list_test.go +++ b/tests/e2e/standalone/list_test.go @@ -170,6 +170,8 @@ func listJsonOutputCheck(t *testing.T, output string) { assert.Equal(t, 4555, int(result[0]["grpcPort"].(float64)), "expected grpc port to match") assert.Equal(t, 0, int(result[0]["appPort"].(float64)), "expected app port to match") assert.GreaterOrEqual(t, int(result[0]["appPid"].(float64)), 0, "expected an app PID (a real value or zero)") + assert.Equal(t, "", result[0]["appLogPath"], "expected app log path to be empty") + assert.Equal(t, "", result[0]["daprdLogPath"], "expected daprd log path to be empty") } func listYamlOutputCheck(t *testing.T, output string) { @@ -185,4 +187,6 @@ func listYamlOutputCheck(t *testing.T, output string) { assert.Equal(t, 4555, result[0]["grpcPort"], "expected grpc port to match") assert.Equal(t, 0, result[0]["appPort"], "expected app port to match") assert.GreaterOrEqual(t, result[0]["appPid"], 0, "expected an app PID (a real value or zero)") + assert.Equal(t, "", result[0]["appLogPath"], "expected app log path to be empty") + assert.Equal(t, "", result[0]["daprdLogPath"], "expected daprd log path to be empty") } diff --git a/tests/e2e/standalone/stop_with_run_template_test.go b/tests/e2e/standalone/stop_with_run_template_test.go index 920d916d5..3a7d2c9d1 100644 --- a/tests/e2e/standalone/stop_with_run_template_test.go +++ b/tests/e2e/standalone/stop_with_run_template_test.go @@ -130,4 +130,6 @@ func assertTemplateListOutput(t *testing.T, name string) { assert.Len(t, result, 2, "expected two apps to be running") assert.Equal(t, name, result[0]["runTemplateName"], "expected run template name to be %s", name) + assert.NotEmpty(t, result[0]["appLogPath"], "expected appLogPath to be non-empty") + assert.NotEmpty(t, result[0]["daprdLogPath"], "expected daprdLogPath to be non-empty") }