AWS Beanstalk - FileNotFoundError:[Errno 2] 没有这样的文件或目录:'/var/app/staging/'

问题描述 投票:0回答:1

我使用的是没有容器的 Elastic Beanstalk,仅使用 EC2 实例。有时创建新实例时会无故失败。我发现了一些奇怪的日志

May 20 20:32:48 ip-172-31-14-242 audit[10978]: AVC avc:  denied  { open } for  pid=10978 comm="nginx" path="/var/log/nginx/error.log" dev="nvme0n1p1" ino=3682049 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:cloud_log_t:s0 tclass=file permissive=1


[2024-05-20T20:21:47.035Z] Sending signal 0 to CFN wait condition https://cloudformation-waitcondition-us-east-1.s3.amazonaws.com/arn%3Aaws%3Acloudformation%3Aus-east-1%3A576017513047%3Astack/awseb-e-xcvkczyzt5-stack/3804c910-892f-11ee-abd9-0a6f02a2186d/AWSEBInstanceLaunchWaitHandle?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20231122T120405Z&X-Amz-SignedHeaders=host&X-Amz-Expires=86399&X-Amz-Credential=AKIA6L7Q4OWT3JRXU3BZ%2F20231122%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=abf31ed864bec2be68aa61889b6b2a836c610de7ba3bed93dce80c1ee7589faa
Error signaling CloudFormation: [Errno 403] HTTP Error 403 : <?xml version="1.0" encoding="UTF-8"?>
<Error><Code>AccessDenied</Code><Message>Request has expired</Message><X-Amz-Expires>86399</X-Amz-Expires><Expires>2023-11-23T12:04:04Z</Expires><ServerTime>2024-05-20T20:21:47Z</ServerTime><RequestId>9SRZ3MVWKVAR7FJ2</RequestId><HostId>B16Ow5bF0aibCFU52u+lnnMOBI6Rijz9KV/Y+UGKWkgHz4E+QtXAbYDp48ZnLK5wAsOHgblLZOk=</HostId></Error>


2024-05-20 19:44:47,211 [ERROR] -----------------------BUILD FAILED!------------------------
2024-05-20 19:44:47,212 [ERROR] Unhandled exception during build: [Errno 2] No such file or directory: '/var/app/staging/'
Traceback (most recent call last):
  File "/opt/aws/bin/cfn-init", line 181, in <module>
    worklog.build(metadata, configSets, strict_mode)
  File "/usr/lib/python3.9/site-packages/cfnbootstrap/construction.py", line 137, in build
    Contractor(metadata, strict_mode).build(configSets, self)
  File "/usr/lib/python3.9/site-packages/cfnbootstrap/construction.py", line 567, in build
    self.run_config(config, worklog)
  File "/usr/lib/python3.9/site-packages/cfnbootstrap/construction.py", line 579, in run_config
    CloudFormationCarpenter(config, self._auth_config, self.strict_mode).build(worklog)
  File "/usr/lib/python3.9/site-packages/cfnbootstrap/construction.py", line 277, in build
    changes['commands'] = CommandTool().apply(
  File "/usr/lib/python3.9/site-packages/cfnbootstrap/command_tool.py", line 116, in apply
    commandResult = LoggingProcessHelper(
  File "/usr/lib/python3.9/site-packages/cfnbootstrap/util.py", line 619, in call
    results = self.process_helper.call()
  File "/usr/lib/python3.9/site-packages/cfnbootstrap/util.py", line 591, in call
    process = subprocess.Popen(
  File "/usr/lib64/python3.9/subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib64/python3.9/subprocess.py", line 1821, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/var/app/staging/'

我知道该文件夹的内容包含我的代码的新版本,但我不管理该文件夹,它是由AWS本身通过cloudformation管理的。有什么解决办法吗?

谢谢

解决启动时没有问题的问题:)

django amazon-web-services amazon-elastic-beanstalk aws-cloudformation
1个回答
0
投票

如果它是 django 应用程序,您可能需要在 .ebextension 文件中配置类似的内容。 app_core 是包含您的settings.py 文件的目录

option_settings:
  aws:elasticbeanstalk:application:environment:
    DJANGO_SETTINGS_MODULE: "dtp_web_core.settings"
    PYTHONPATH: "/var/app/current:$PYTHONPATH"
  aws:elasticbeanstalk:container:python:
    WSGIPath: "dtp_web_core.wsgi:application"
  aws:elasticbeanstalk:environment:proxy:staticfiles:
    /static: staticfiles
© www.soinside.com 2019 - 2024. All rights reserved.