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

Added wait-after-import (-W) option #89

Merged
merged 1 commit into from
Oct 4, 2017
Merged
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ for organization name, all of which are required.
`--virtualhosts -v`
(optional) A comma-separated list of virtual hosts that the deployed app will use. The two most common options are `default` and `secure`. The `default` option is always HTTP and `secure` is always HTTPS. By default, `apigeetool deploynodeapp` uses `default,secure`.

`--wait-after-import -W`
(optional) Number of seconds to delay before deploying node.js proxy.

## <a name="deployproxy"></a>deployproxy

Deploys an API proxy to Apigee Edge. If the proxy is currently deployed, it will be undeployed first, and the newly deployed proxy's revision number is incremented.
Expand Down Expand Up @@ -212,6 +215,9 @@ for organization name, all of which are required.
`--upload-modules -U`
(optional) If specified, uploads Node.js modules from your system to Apigee Edge.

`--wait-after-import -W`
(optional) Number of seconds to delay before deploying node.js proxy.

## <a name="undeploy"></a>undeploy

Undeploys a named API proxy or Node.js app deployed on Apigee Edge.
Expand Down
21 changes: 20 additions & 1 deletion lib/commands/deploynodeapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ var descriptor = defaults.defaultDescriptor({
name: 'Preserve policies from previous revision',
shortOption: 'P',
toggle: true
},
'wait-after-import': {
name: 'Wait N seconds after importing proxy before deploying',
shortOption: 'W',
required: false
}
});
module.exports.descriptor = descriptor;
Expand All @@ -84,7 +89,18 @@ module.exports.format = function(r) {
return result;
};


module.exports.run = function(opts, cb) {
// Setup Delay for after import if set
opts.waitAfterImportDelay = 0;
if (opts['wait-after-import'] !== undefined) {
opts.waitAfterImportDelay = parseInt(opts['wait-after-import']);
if (isNaN(opts.waitAfterImportDelay)) {
console.error('invalid int for wait-after-import');
process.exit(1);
}
}

if (!opts.directory) {
opts.directory = process.cwd();
}
Expand Down Expand Up @@ -679,5 +695,8 @@ function deployProxy(opts, request, done) {
tasks[env] = deployToEnvironment.bind(this, env);
});

async.parallel(tasks, done);
if (opts.verbose) { console.log('Delaying deployment for %d seconds', opts.waitAfterImportDelay); }
setTimeout(function () {
async.parallel(tasks, done);
}, opts.waitAfterImportDelay*1000);
}
21 changes: 20 additions & 1 deletion lib/commands/deployproxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ var descriptor = defaults.defaultDescriptor({
name: 'Upload Modules',
shortOption: 'U',
toggle: true
},
'wait-after-import': {
name: 'Wait N seconds after importing proxy before deploying',
shortOption: 'W',
required: false
}
});
module.exports.descriptor = descriptor;
Expand All @@ -70,6 +75,17 @@ module.exports.format = function(r) {
};

module.exports.run = function(opts, cb) {
// Setup Delay for after import if set
opts.waitAfterImportDelay = 0;
if (opts['wait-after-import'] !== undefined) {
opts.waitAfterImportDelay = parseInt(opts['wait-after-import']);
if (isNaN(opts.waitAfterImportDelay)) {
console.error('invalid int for wait-after-import');
process.exit(1);
}
}


if (!opts.directory) {
opts.directory = process.cwd();
}
Expand Down Expand Up @@ -660,5 +676,8 @@ function deployProxy(opts, request, done) {
tasks[env] = deployToEnvironment.bind(this, env);
});

async.parallel(tasks, done);
if (opts.verbose) { console.log('Delaying deployment for %d seconds', opts.waitAfterImportDelay); }
setTimeout(function () {
async.parallel(tasks, done);
}, opts.waitAfterImportDelay*1000);
}