Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add output flag to sync status command #1010

Merged
merged 1 commit into from
Jun 30, 2022

Conversation

kasteph
Copy link
Contributor

@kasteph kasteph commented Jun 26, 2022

Background

I frequently have to stop a Lily daemon manually when I do backfills or partial repository archiving work. Until filecoin-project/lotus#8641 is ready, I need to be able to have a way to determine what the latest height is.

Changes

This PR accepts a string flag to the stop command that determines at the most recent height the given stage stopped. This allows me to use the height in stdout to be used as an input for next steps in the data pipeline.

It accepts a bool flag to sync called output that would enable me to continuously poll the sync command with simple bash one-liners and check at what stage and what height it currently is at.

e.g.

❯ ./lily sync status --output="text"
2022-06-27T13:11:35.035+0200    WARN    cliutil util/apiinfo.go:81      API Token not set and requested, capabilities might be limited.
header sync 1072527
❯ ./lily sync status --output="json"
2022-06-27T16:16:06.003+0200    WARN    cliutil util/apiinfo.go:81      API Token not set and requested, capabilities might be limited.
{"Stage":1,"Height":1075951}

@kasteph kasteph requested review from iand and frrist June 26, 2022 22:49
@kasteph kasteph changed the title chore: add sync height command chore: add height flag to stop command Jun 26, 2022
commands/stop.go Outdated Show resolved Hide resolved
@kasteph kasteph requested review from placer14 June 27, 2022 09:55
commands/sync.go Outdated Show resolved Hide resolved
commands/sync.go Outdated Show resolved Hide resolved
commands/stop.go Outdated Show resolved Hide resolved
commands/sync.go Outdated Show resolved Hide resolved
commands/sync.go Show resolved Hide resolved
commands/sync.go Outdated Show resolved Hide resolved
@kasteph kasteph force-pushed the kasteph/get-sync-height branch from 48276b3 to 80610ef Compare June 29, 2022 22:09
@kasteph kasteph requested a review from frrist June 29, 2022 22:10
Copy link
Member

@frrist frrist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :shipit:

} else {
fmt.Printf("\tElapsed: %s\n", ss.End.Sub(ss.Start))
fmt.Printf(string(j) + "\n")
case "":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could call this "pretty" or "verbose" and set the default value of the --output flag as such, but not a big deal

@kasteph kasteph changed the title chore: add height flag to stop command chore: add output flag to sync status command Jun 30, 2022
@kasteph kasteph force-pushed the kasteph/get-sync-height branch from 80610ef to 30fbe57 Compare June 30, 2022 09:09
@kasteph kasteph merged commit f150334 into master Jun 30, 2022
@kasteph kasteph deleted the kasteph/get-sync-height branch June 30, 2022 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants