使用 Google Cloud Functions 的无服务器包装器



我正在尝试使用无服务器和谷歌云函数编写自定义包装器。

const serverless = new Serverless({
interactive: false,
servicePath: "/Users/user/work/faas-artillery"
})
var options = {
function: 'my-function',
stage: 'my-stage',
region: 'my-region'
};
//console.log(options)
// Set the serverless artillery to use Google. 
// This constructor then adds Google plugins to the serverless framework
var googleIndex = new GoogleIndex(serverless, options);
serverless.init();
// Now find the GoogleInvoke by constructor name within the serverless 
const invoke = serverless.pluginManager.plugins.find(
plugin => Object.getPrototypeOf(plugin).constructor.name === 'GoogleInvoke' 
)
serverless.run()

在执行上述命令时,我收到未找到调用命令。

有没有办法为无服务器分配 CLI 选项?

serverless.init(( 方法存在一个承诺,我们必须等待它完成。

let googleInvoke;
let SLS_DEBUG
SLS_DEBUG = process.env.SLS_DEBUG
process.env.SLS_DEBUG = '*'
// pretend that SLS was called.
process.argv[1] = Serverless.dirname
const serverless = new Serverless({
interactive: false,
servicePath: "/Users/user/work/faas-artillery"
})
var options = {
function: 'my-function',
stage: 'my-stage',
region: 'my-region'
};
//console.log(options)
// Set the serverless artillery to use Google. 
// This constructor then adds Google plugins to the serverless framework
var googleIndex = new GoogleIndex(serverless, options);
serverless.init().then(() => {
// Now find the GoogleInvoke by constructor name within the serverless 
const invoke = serverless.pluginManager.plugins.find(
plugin => Object.getPrototypeOf(plugin).constructor.name === 'GoogleInvoke' 
)
}).then(() => {
serverless.run()
});

相关内容

  • 没有找到相关文章

最新更新