首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Serverless/Bref中将命令行参数传递给Lambda函数?

如何在Serverless/Bref中将命令行参数传递给Lambda函数?
EN

Stack Overflow用户
提问于 2019-08-13 23:14:55
回答 1查看 1.9K关注 0票数 1

我正在使用Bref (使用无服务器)在AWS Lambda上运行Symfony 4 (PHP)应用程序。

Bref为Symfony的bin/console二进制文件提供了一个层。Lambda函数的无服务器配置如下所示:

代码语言:javascript
复制
functions:
    console:
        handler: bin/console
        name: 'mm-console'
        description: 'Symfony 4 console'
        timeout: 120 # in seconds
        layers:
            - ${bref:layer.php-73} # PHP
            - ${bref:layer.console} # The "console" layer

使用上面的代码,我可以在Lambda上运行vendor/bin/bref cli mm-console -- mm:find-matches来运行bin/console mm:find-matches

如果我想在Lambda上按计划运行mm:find-matches控制台命令,该怎么办?我试过这个:

代码语言:javascript
复制
functions:
    mm-find-matches:
        handler: "bin/console mm:find-matches"
        name: 'mm-find-matches'
        description: 'Find mentor matches'
        timeout: 120
        layers:
            - ${bref:layer.php-73} # PHP
            - ${bref:layer.console} # The "console" layer
        schedule:
            rate: rate(2 hours)

但是,"bin/console mm:find-matches“不是有效的处理程序。如何按计划向bin/console函数传递mm:find-matches命令?

EN

回答 1

Stack Overflow用户

发布于 2019-08-14 00:03:48

您可以通过调度事件输入传递命令行参数,如下所示:

代码语言:javascript
复制
functions:
    console:
        handler: bin/console
        name: 'mm-console'
        description: 'Symfony 4 console'
        timeout: 120 # in seconds
        layers:
            - ${bref:layer.php-73} # PHP
            - ${bref:layer.console} # The "console" layer
        events:
            - schedule:
                input:
                    cli: "mm:find-matches --env=test"
                rate: rate(2 hours)
                enabled: true

尽管在this bref github issue上有一些关于使用cli控制台应用程序是否是最好的解决方案的讨论,但还是与编写引导内核并执行您希望命令完成的特定任务的函数相比。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57480766

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档