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

Add standard command-line flags #37

Merged
merged 2 commits into from
Oct 3, 2015
Merged

Conversation

chriskuehl
Copy link
Contributor

no arguments

ckuehl@dev15-devc:~/proj/dumb-init$ ./dumb-init
Usage: ./dumb-init [option] program [args]
Try ./dumb-init --help for full usage.

--help / -h

ckuehl@dev15-devc:~/proj/dumb-init$ ./dumb-init --help
dumb-init v0.4.0
Usage: ./dumb-init [option] command [[arg] ...]

dumb-init is a simple process supervisor that forwards signals to children.
It is designed to run as PID1 in minimal container environments.

Optional arguments:
   -c, --single-child   Run in single-child mode.
                        In this mode, signals are only proxies to the
                        direct child and not any of its ancestors.
   -v, --verbose        Print debugging information to stderr.
   -h, --help           Print this help message and exit.
   -V, --version        Print the current version and exit.

Full help is available online at https://github.com/Yelp/dumb-init
ckuehl@dev15-devc:~/proj/dumb-init$ ./dumb-init -v
Usage: ./dumb-init [option] program [args]
Try ./dumb-init --help for full usage.

--version / -V

ckuehl@dev15-devc:~/proj/dumb-init$ ./dumb-init --version
dumb-init v0.4.0

--verbose / -v

ckuehl@dev15-devc:~/proj/dumb-init$ ./dumb-init -v echo hi
[dumb-init] Child spawned with PID 1392587.
[dumb-init] setsid complete.
hi
[dumb-init] A child with PID 1392587 exited with exit status 0.
[dumb-init] Forwarded signal 15 to children.
[dumb-init] Child exited with status 0. Goodbye.

--single-child --verbose / -cv

ckuehl@dev15-devc:~/proj/dumb-init$ ./dumb-init -cv echo hi
[dumb-init] Child spawned with PID 1392920.
hi
[dumb-init] A child with PID 1392920 exited with exit status 0.
[dumb-init] Forwarded signal 15 to children.
[dumb-init] Child exited with status 0. Goodbye.

VERSION.h: VERSION
echo '// THIS FILE IS AUTOMATICALLY GENERATED' > VERSION.h
echo '// Run `make VERSION.h` to update it after modifying VERSION.' >> VERSION.h
xxd -i VERSION >> VERSION.h
Copy link
Contributor Author

Choose a reason for hiding this comment

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

can't really decide if this is better than just duplicating the version in the C file or not...

unfortunately there doesn't seem to be a good way to have the C preprocessor read from a file into a string

Copy link
Contributor

Choose a reason for hiding this comment

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

I always side with no duplication of data.

// THIS FILE IS AUTOMATICALLY GENERATED
// Run `make VERSION.h` to update it after modifying VERSION.
unsigned char VERSION[] = {
0x30, 0x2e, 0x34, 0x2e, 0x30, 0x0a
Copy link
Contributor

Choose a reason for hiding this comment

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

lols

Copy link
Contributor Author

Choose a reason for hiding this comment

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

:(
I hate committing build artifacts but I don't know of a better way to handle this. The alternative is duplicate the version into the top of the C file. But then we need to maintain versions in sync in README/setup.py/dumb-init.c/debian changelog.

Copy link
Contributor

Choose a reason for hiding this comment

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

I just thought the ascii byte representation was funny is all.

@bukzor
Copy link
Contributor

bukzor commented Oct 3, 2015

The five cases you put in your description I'd actually do under test.

It sounds like a pain / duplication of data to do it like that, but its always been worth the cost to have the test suite tell me when I've derped up the messaging. Plus, even when it's doing what you meant to, often you only notice the output could be improved when you see it fully written out, under test.

But that's just me. Looks good apart from that nit. :shipit:

bukzor pushed a commit that referenced this pull request Oct 3, 2015
@bukzor bukzor merged commit 5e8e55c into Yelp:master Oct 3, 2015
@bukzor bukzor mentioned this pull request Oct 6, 2015
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.

2 participants