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

Clean parameter for 'pig down' command #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ And use `pig start mongoshell` whenever you need mongo shell access.
* `logs CONTAINER [opts]` - show `docker logs` output for container with the given `opts` (`-t` for tail, `-f` for follow, anything `docker logs` accepts)
* `inspect CONTAINER` - show `docker inspect` output for container
* `up [-R|--no-recreate]` - start all daemons
* `down` - stop all daemons
* `down [-rm|--clean]` - stop all daemons (and delete containers)

The default behaviour is that containers are re-created every time when `start` or `up` command is executed.
If you want to prevent this behaviour and start existing container instead, add either `-R` or
Expand Down
5 changes: 3 additions & 2 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ function parseArgs(args) {
var remainder = args.slice(recreate ? 2 : 3)
var interactive = !(process.env["NONINTERACTIVE"] === 'true')
var verbose = process.env["VERBOSE"] === 'true'
var clean = _.contains(['--clean', '-rm'], args[1])

return {
command: command,
name: name,
remainder: remainder,
options: { interactive: interactive, verbose: verbose, recreate: recreate },
options: { interactive: interactive, verbose: verbose, recreate: recreate, clean: clean },
}
}

Expand Down Expand Up @@ -93,7 +94,7 @@ function main(args, callback) {
break

case "down":
commands.stopDaemons(callback)
commands.stopDaemons({ clean: args.options.clean }, callback)
break

case "logs":
Expand Down
4 changes: 2 additions & 2 deletions lib/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ module.exports = function(containers, options) {
}, done)
}

function stopDaemons(done) {
function stopDaemons(stopOptions, done) {
done = done || _.noop

var daemons = _.filter(containers, { daemon: true })
helpers.asyncIterate(daemons, function(container, next) {
stop(container, null, next)
stop(container, {removeStopped: stopOptions.clean}, next)
}, done)
}

Expand Down