mirror of
https://github.com/danbulant/docker-compose
synced 2026-06-24 17:31:53 +00:00
Merge pull request #36 from PDMLab/feature-restart
implement restart command
This commit is contained in:
commit
b14aa2dfa5
3 changed files with 63 additions and 1 deletions
3
index.d.ts
vendored
3
index.d.ts
vendored
|
|
@ -6,6 +6,9 @@ declare module "docker-compose" {
|
||||||
kill(options: IDockerComposeOptions): Promise<IDockerComposeResult>;
|
kill(options: IDockerComposeOptions): Promise<IDockerComposeResult>;
|
||||||
down(options: IDockerComposeOptions): Promise<IDockerComposeResult>;
|
down(options: IDockerComposeOptions): Promise<IDockerComposeResult>;
|
||||||
stop(options: IDockerComposeOptions): Promise<IDockerComposeResult>;
|
stop(options: IDockerComposeOptions): Promise<IDockerComposeResult>;
|
||||||
|
restartAll(options: IDockerComposeOptions): Promise<IDockerComposeResult>;
|
||||||
|
restartMany(services:String[], options: IDockerComposeOptions): Promise<IDockerComposeResult>;
|
||||||
|
restartOne(service:String, options: IDockerComposeOptions): Promise<IDockerComposeResult>;
|
||||||
rm(options: IDockerComposeOptions): Promise<IDockerComposeResult>;
|
rm(options: IDockerComposeOptions): Promise<IDockerComposeResult>;
|
||||||
exec(container:String, command:String, options: IDockerComposeOptions): Promise<IDockerComposeResult>;
|
exec(container:String, command:String, options: IDockerComposeOptions): Promise<IDockerComposeResult>;
|
||||||
run(service:String, command:String, options: IDockerComposeOptions): Promise<IDockerComposeResult>;
|
run(service:String, command:String, options: IDockerComposeOptions): Promise<IDockerComposeResult>;
|
||||||
|
|
|
||||||
37
index.js
37
index.js
|
|
@ -233,4 +233,39 @@ const ps = function (options) {
|
||||||
return execCompose('ps', [], options);
|
return execCompose('ps', [], options);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = { upAll, upMany, upOne, kill, down, stop, rm, exec, run, buildAll, buildMany, buildOne, ps };
|
/**
|
||||||
|
* @param {object} options
|
||||||
|
* @param {string} options.cwd
|
||||||
|
* @param {boolean} [options.log]
|
||||||
|
* @param {?(string|string[])} [options.config]
|
||||||
|
* @param {?object} [options.env]
|
||||||
|
*/
|
||||||
|
const restartAll = function (options) {
|
||||||
|
return execCompose('restart', [], options);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string[]} services
|
||||||
|
* @param {object} options
|
||||||
|
* @param {string} options.cwd
|
||||||
|
* @param {boolean} [options.log]
|
||||||
|
* @param {?(string|string[])} [options.config]
|
||||||
|
* @param {?object} [options.env]
|
||||||
|
*/
|
||||||
|
const restartMany = function (services, options) {
|
||||||
|
return execCompose('restart', services, options);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} service
|
||||||
|
* @param {object} options
|
||||||
|
* @param {string} options.cwd
|
||||||
|
* @param {boolean} [options.log]
|
||||||
|
* @param {?(string|string[])} [options.config]
|
||||||
|
* @param {?object} [options.env]
|
||||||
|
*/
|
||||||
|
const restartOne = function (service, options) {
|
||||||
|
return restartMany([ service ], options);
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = { upAll, upMany, upOne, kill, down, stop, rm, exec, restartAll, restartMany, restartOne, run, buildAll, buildMany, buildOne, ps };
|
||||||
|
|
|
||||||
|
|
@ -245,3 +245,27 @@ test('ps does not show status data for stopped containers', async assert => {
|
||||||
|
|
||||||
assert.end();
|
assert.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('restartAll does restart all containers', async assert => {
|
||||||
|
await compose.upAll({ cwd: path.join(__dirname), log: true });
|
||||||
|
await compose.restartAll({ cwd: path.join(__dirname), log: true });
|
||||||
|
|
||||||
|
assert.true(await isContainerRunning('/compose_test_mongodb'));
|
||||||
|
assert.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('restartMany does restart selected containers', async assert => {
|
||||||
|
await compose.upAll({ cwd: path.join(__dirname), log: true });
|
||||||
|
await compose.restartMany([ 'db', 'alpine' ], { cwd: path.join(__dirname), log: true });
|
||||||
|
|
||||||
|
assert.true(await isContainerRunning('/compose_test_mongodb'));
|
||||||
|
assert.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('restartOne does restart container', async assert => {
|
||||||
|
await compose.upAll({ cwd: path.join(__dirname), log: true });
|
||||||
|
await compose.restartOne('db', { cwd: path.join(__dirname), log: true });
|
||||||
|
|
||||||
|
assert.true(await isContainerRunning('/compose_test_mongodb'));
|
||||||
|
assert.end();
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue