创建应用程序源包AWS Elastic Beanstalk

Posted cloudrivers

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了创建应用程序源包AWS Elastic Beanstalk相关的知识,希望对你有一定的参考价值。

使用 AWS Elastic Beanstalk 控制台部署新应用程序或应用程序版本时,需要上传源包。源包必须符合以下要求:

  • 由单个 ZIP 文件或 WAR 文件组成 (您可以在 WAR 文件中包含多个 ZIP 文件)

  • 不超过 512 MB

  • 不包含父文件夹或顶级目录 (可包含子目录)

如果您要部署处理定期后台任务的工作线程应用程序,您的应用程序源包还必须包括一个 cron.yaml 文件。

~/myapp$ zip ../myapp.zip -r * .[^.]*
  adding: app.js (deflated 63%)
  adding: index.js (deflated 44%)
  adding: manual.js (deflated 64%)
  adding: package.json (deflated 40%)
  adding: restify.js (deflated 85%)
  adding: .ebextensions/ (stored 0%)
  adding: .ebextensions/xray.config (stored 0%)
from flask import Flask

# print a nice greeting.
def say_hello(username = "World"):
    return <p>Hello %s!</p>\n % username

# some bits of text for the page.
header_text = ‘‘‘
    <html>\n<head> <title>EB Flask Test</title> </head>\n<body>‘‘‘
instructions = ‘‘‘
    <p><em>Hint</em>: This is a RESTful web service! Append a username
    to the URL (for example: <code>/Thelonious</code>) to say hello to
    someone specific.</p>\n‘‘‘
home_link = <p><a href="/">Back</a></p>\n
footer_text = </body>\n</html>

# EB looks for an ‘application‘ callable by default.
application = Flask(__name__)

# add a rule for the index page.
application.add_url_rule(/, index, (lambda: header_text +
    say_hello() + instructions + footer_text))

# add a rule when the page is accessed with a name appended to the site
# URL.
application.add_url_rule(/<username>, hello, (lambda username:
    header_text + say_hello(username) + home_link + footer_text))

# run the app.
if __name__ == "__main__":
    # Setting debug to True enables debug output. This line should be
    # removed before deploying a production app.
    application.debug = True
    application.run()

 

以上是关于创建应用程序源包AWS Elastic Beanstalk的主要内容,如果未能解决你的问题,请参考以下文章

在 AWS Elastic Beanstalk 上使用 Docker 进行 Django 迁移

Amazon Elastic BeanStalk 错误:无法创建 AWS Elastic Beanstalk 应用程序版本

Spring AWS:在 Elastic Beanstalk 上部署战争时访问被拒绝错误

创建 AWS Elastic Beanstalk Ruby/Rails 应用程序环境 [AWS 免费套餐] 时使用了哪些 AWS 资源/服务?

AWS EBS 错误:源包为空或超过允许的最大大小:524288000

未为 AWS Elastic beanstalk 创建 s3 存储桶