Skip to content

Commit

Permalink
feat: allow server-manager to bypass log config
Browse files Browse the repository at this point in the history
A workaround so Sunodo can display only the application output on its log
  • Loading branch information
torives committed Mar 11, 2024
1 parent fd444de commit b61c1e9
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

### Added

- Added `CARTESI_EXPERIMENTAL_SERVER_MANAGER_LOG_BYPASS_ENABLED` env var to allow `server-manager` output to bypass all log configuration

## [1.3.0] 2024-02-09

### Added
Expand Down
8 changes: 8 additions & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ Address of the InputBox contract.

* **Type:** `string`

## `CARTESI_EXPERIMENTAL_SERVER_MANAGER_LOG_BYPASS_ENABLED`

When enabled, prints server-manager output to stdout and stderr directly.

Check failure on line 136 in docs/config.md

View workflow job for this annotation

GitHub Actions / assess-code-quality

Trailing spaces

docs/config.md:136:74 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1] https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md009.md
All other log configurations are ignored

* **Type:** `bool`
* **Default:** `"false"`

## `CARTESI_EXPERIMENTAL_SUNODO_VALIDATOR_ENABLED`

When enabled, the node does not start the authority-claimer service and the Redis server.
Expand Down
6 changes: 6 additions & 0 deletions internal/config/generate/Config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,9 @@ go-type = "string"
description = """
External Redis endpoint for the node when running in the experimental sunodo validator mode."""

[experimental.CARTESI_EXPERIMENTAL_SERVER_MANAGER_LOG_BYPASS_ENABLED]
default = "false"
go-type = "bool"
description = """
When enabled, prints server-manager output to stdout and stderr directly.
All other log configurations are ignored."""
5 changes: 5 additions & 0 deletions internal/config/get.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions internal/services/server-manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"context"
"fmt"
"net"
"os"
"os/exec"
"strconv"
"strings"
Expand Down Expand Up @@ -41,8 +42,13 @@ const waitDelay = 200 * time.Millisecond
func (s ServerManager) Start(ctx context.Context, ready chan<- struct{}) error {
cmd := exec.CommandContext(ctx, s.Path, s.Args...)
cmd.Env = s.Env
cmd.Stderr = newLineWriter(commandLogger{s.Name})
cmd.Stdout = newLineWriter(commandLogger{s.Name})
if config.GetCartesiExperimentalServerManagerLogBypassEnabled() {
cmd.Stderr = os.Stderr
cmd.Stdout = os.Stdout
} else {
cmd.Stderr = newLineWriter(commandLogger{s.Name})
cmd.Stdout = newLineWriter(commandLogger{s.Name})
}
// Without a delay, cmd.Wait() will block forever waiting for the I/O pipes
// to be closed
cmd.WaitDelay = waitDelay
Expand Down

0 comments on commit b61c1e9

Please sign in to comment.