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

# Conflicts:
#	CHANGELOG.md
  • Loading branch information
torives committed Mar 15, 2024
1 parent a7057b8 commit b0cff76
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ 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
## [Unreleased]

### Added

- Added verification to ensure CARTESI_BLOCKCHAIN_ID matches the id returned from the Ethereum node
- Added support for CARTESI_AUTH_PRIVATE_KEY and CARTESI_AUTH_PRIVATE_KEY_FILE
- Added `CARTESI_EXPERIMENTAL_SERVER_MANAGER_BYPASS_LOG` env var to allow `server-manager` output to bypass all log configuration

## Changed

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

* **Type:** `string`

## `CARTESI_EXPERIMENTAL_SERVER_MANAGER_BYPASS_LOG`

When enabled, prints server-manager output to stdout and stderr directly.
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 @@ -256,3 +256,9 @@ go-type = "string"
description = """
External Redis endpoint for the node when running in the experimental sunodo validator mode."""

[experimental.CARTESI_EXPERIMENTAL_SERVER_MANAGER_BYPASS_LOG]
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.GetCartesiExperimentalServerManagerBypassLog() {
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 b0cff76

Please sign in to comment.