【发布时间】:2022-01-23 15:05:20
【问题描述】:
我正在尝试通过在 aws ec2 上运行自定义检测脚本来进行一些对象检测。我为实例添加了如下用户数据脚本
Content-Type: multipart/mixed; boundary="//"
MIME-Version: 1.0
--//
Content-Type: text/cloud-config; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="cloud-config.txt"
#cloud-config
cloud_final_modules:
- [scripts-user, always]
--//
Content-Type: text/x-shellscript; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="userdata.txt"
#!/bin/sh
cd /home/ubuntu/path/to/script
sudo python3 strawberry_count_new.py
但是,当我的 lambda 函数将图像复制到实例时,脚本不会执行检测。我没有得到任何输出。当我检查我正在运行的进程时,python 脚本正在运行。我不确定为什么它不处理来自 s3 的输入图像。当我在实例中运行相同的脚本时,它会处理相同的输入图像。
【问题讨论】:
-
通常我们忘记了用户的脚本是从root用户运行的。您是否使用相同的 root 用户?
-
@Nirmal 我如何检查我是否使用 root 用户?
标签: python-3.x amazon-web-services amazon-s3 amazon-ec2 aws-lambda