Skip to content
This repository was archived by the owner on Dec 1, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fixing timeout and no-log-prefix flags logic
  • Loading branch information
mRrvz committed Feb 2, 2021
commit 41cc7d0d813bbebb7712fbacfa6bd8515689484c
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Added

- `--no-log-prefix` option for `cartridge start` command to disable instance name prefix in logs
- `--no-log-prefix` option for `cartridge start` command to disable instance name prefix in logs when running interactively.

## [2.6.0] - 2021-01-27

Expand Down
12 changes: 7 additions & 5 deletions cli/commands/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func init() {
// stateboard flags
addStateboardRunningFlags(startCmd)

// Disable instance(s) prefix flag
// Disable instance name prefix in logs flag
startCmd.Flags().BoolVar(&ctx.Running.DisableLogPrefix, "no-log-prefix", false, disableLogPrefixUsage)

// common running paths
Expand All @@ -57,10 +57,12 @@ func init() {
func runStartCmd(cmd *cobra.Command, args []string) error {
var err error

if timeoutStr == "" {
ctx.Running.DefaultTimeout = true
} else {
ctx.Running.DefaultTimeout = false
if timeoutStr == "" && !ctx.Running.Daemonize {
log.Warnf("--timeout flag is ignored due to starting instances interactively")
}

if ctx.Running.DisableLogPrefix && ctx.Running.Daemonize {
log.Warnf("--no-log-prefix flag is ignored due to startring instances in background")
}

if err := setDefaultValue(cmd.Flags(), "timeout", defaultStartTimeout.String()); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cli/commands/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ defaults to ./instances.yml ("cfg" in .cartridge.yml)`

stopForceUsage = `Force instance(s) stop (sends SIGKILL)`

disableLogPrefixUsage = `Disable instance(s) prefix in logs`
disableLogPrefixUsage = `Disable prefix in logs when run interactively`
)

// REPLICASETS
Expand Down
5 changes: 2 additions & 3 deletions cli/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ type RunningCtx struct {
WithStateboard bool
StateboardOnly bool

Daemonize bool
DefaultTimeout bool
StartTimeout time.Duration
Daemonize bool
StartTimeout time.Duration

LogFollow bool
LogLines int
Expand Down
8 changes: 0 additions & 8 deletions cli/running/running.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,6 @@ func Start(ctx *context.Ctx) error {
log.Warnf("Failed to check .rocks directory: %s", err)
}

if ctx.Running.DisableLogPrefix && ctx.Running.Daemonize {
log.Warnf("--no-log-prefix flag will be ignored.")
}

if !ctx.Running.Daemonize && !ctx.Running.DefaultTimeout {
log.Warnf("--timeout flag will be ignored.")
}

if err := processes.Start(ctx.Running.Daemonize, ctx.Running.DisableLogPrefix, ctx.Running.StartTimeout); err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions test/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ def __init__(self, cartridge_cmd):
self._instance_pids = set()
self._subprocess = None

def start(self, project, instances=[], daemonized=False, stateboard=False,
stateboard_only=False, cfg=None, script=None, run_dir=None, data_dir=None,
log_dir=None, timeout=None, capture_output=False, exp_rc=0):
def start(self, project, instances=[], daemonized=False, stateboard=False, stateboard_only=False,
cfg=None, script=None, run_dir=None, data_dir=None, log_dir=None, timeout=None,
capture_output=False, exp_rc=0):
cmd = [self._cartridge_cmd, 'start']
if daemonized:
cmd.append('-d')
Expand Down