创建应用程序源包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()

猜你喜欢

转载自www.cnblogs.com/cloudrivers/p/11620899.html