mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
58 lines
1.6 KiB
JavaScript
Executable File
58 lines
1.6 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
'use strict';
|
|
|
|
const autocomplete = require('../lib/utils/autocomplete');
|
|
const BbPromise = require('bluebird');
|
|
const platform = require('@serverless/platform-sdk');
|
|
const logError = require('../lib/classes/Error').logError;
|
|
const uuid = require('uuid');
|
|
const initializeErrorReporter = require('../lib/utils/sentry').initializeErrorReporter;
|
|
|
|
Error.stackTraceLimit = Infinity;
|
|
|
|
if (process.env.SLS_DEBUG) {
|
|
// For performance reasons enabled only in SLS_DEBUG mode
|
|
BbPromise.config({
|
|
longStackTraces: true,
|
|
});
|
|
}
|
|
|
|
process.on('unhandledRejection', (e) => {
|
|
logError(e);
|
|
});
|
|
process.noDeprecation = true;
|
|
|
|
const invocationId = uuid.v4();
|
|
|
|
// boot up error reporting via sentry before anything
|
|
(() => initializeErrorReporter(invocationId).then(() => {
|
|
if (process.argv[2] === 'completion') {
|
|
return autocomplete();
|
|
}
|
|
// requiring here so that if anything went wrong,
|
|
// during require, it will be caught.
|
|
const Serverless = require('../lib/Serverless'); // eslint-disable-line global-require
|
|
|
|
const serverless = new Serverless({
|
|
interactive: typeof process.env.CI === 'undefined',
|
|
});
|
|
|
|
serverless.invocationId = invocationId;
|
|
|
|
return serverless.init().then(() => serverless.run()).catch((e) => {
|
|
if (serverless.service.deployment && serverless.service.deployment.deploymentId) {
|
|
const deploymentData = serverless.service.deployment;
|
|
deploymentData.status = 'Failed';
|
|
return platform.updateDeployment(deploymentData)
|
|
.then(() => {
|
|
throw e;
|
|
});
|
|
}
|
|
throw e;
|
|
});
|
|
}).catch(e => {
|
|
process.exitCode = 1;
|
|
logError(e);
|
|
}))();
|