在Web部署时组件安装无法连接Greengrass Core IPC。

0

【以下的问题经过翻译处理】 介绍

我使用gdk component build生成了一个组件的artifacts和recipe,并位于生成的greengrass-build文件夹中。

文件夹结构屏幕截图如下。

Enter image description here

这是生成的recipe.yml文件。gdk已配置为构建artifacts为zip。

ComponentConfiguration:
  DefaultConfiguration:
    accessControl:
      aws.greengrass.ipc.mqttproxy:
        com.twisthink.SystemController:mqttproxy:1:
          operations:
          - aws.greengrass#SubscribeToIoTCore
          policyDescription: 允许访问订阅 IoT Core 主题
          resources:
          - $aws/things/{iot:thingName}/jobs/get/accepted
          - $aws/things/{iot:thingName}/jobs/get/rejected
        com.twisthink.SystemController:mqttproxy:2:
          operations:
          - aws.greengrass#PublishToIoTCore
          policyDescription: 允许访问发布到 IoT Core 主题
          resources:
          - $aws/things/{iot:thingName}/jobs/get
ComponentDescription: 这是用Python编写的简单的Hello World组件。
ComponentName: myExample
ComponentPublisher: myname
ComponentVersion: 1.0.1
Manifests:
- Artifacts:
  - URI: s3://BUCKET_NAME/COMPONENT_NAME/COMPONENT_VERSION/example.zip
    Unarchive: ZIP
  Lifecycle:
    Run:
      RequiresPrivilege: true
      Script: sudo python3 {artifacts:decompressedPath}/example/main.py
  Platform:
    os: linux
RecipeFormatVersion: '2020-01-25'

接下来,我运行以下命令本地部署组件。

cd greengrass-build
sudo greengrass-cli deployment create --recipeDir recipes --artifactDir artifacts --merge "myExample=1.0.1"

问题

我在....greengrass/v2/logs/myExample.log中看到报错如下: 2023-02-10T21:10:17.518Z [WARN] (Copier) myExample: stderr. File "/home/me/greengrass/v2/packages/artifacts-unarchived/myExample/1.0.1/example/main.py", line 41, in init. {scriptName=services.myExample.lifecycle.Run.Script, serviceName=myExample, currentState=RUNNING} 2023-02-10T21:10:17.518Z [WARN] (Copier) myExample: stderr. self.ipc_client_v2 = GreengrassCoreIPCClientV2(). {scriptName=services.myExample.lifecycle.Run.Script, serviceName=myExample, currentState=RUNNING} 2023-02-10T21:10:17.518Z [WARN] (Copier) myExample: stderr. File "/usr/local/lib/python3.8/dist-packages/awsiot/greengrasscoreipc/clientv2.py", line 31, in init. {scriptName=services.myExample.lifecycle.Run.Script, serviceName=myExample, currentState=RUNNING} 2023-02-10T21:10:17.518Z [WARN] (Copier) myExample: stderr. client = awsiot.greengrasscoreipc.connect(). {scriptName=services.myExample.lifecycle.Run.Script, serviceName=myExample, currentState=RUNNING} 2023-02-10T21:10:17.518Z [WARN] (Copier) myExample: stderr. File "/usr/local/lib/python3.8/dist-packages/awsiot/greengrasscoreipc/init.py", line 45, in connect. {scriptName=services.myExample.lifecycle.Run.Script, serviceName=myExample, currentState=RUNNING} 2023-02-10T21:10:17.518Z [WARN] (Copier) myExample: stderr. ipc_socket = os.environ["AWS_GG_NUCLEUS_DOMAIN_SOCKET_FILEPATH_FOR_COMPONENT"]. {scriptName=services.myExample.lifecycle.Run.Script, serviceName=myExample, currentState=RUNNING} 2023-02-10T21:10:17.518Z [WARN] (Copier) myExample: stderr. File "/usr/lib/python3.8/os.py", line 675, in getitem. {scriptName=services.myExample.lifecycle.Run.Script, serviceName=myExample, currentState=RUNNING} 2023-02-10T21:10:17.518Z [WARN] (Copier) myExample: stderr. raise KeyError(key) from None. {scriptName=services.myExample.lifecycle.Run.Script, serviceName=myExample, currentState=RUNNING} 2023-02-10T21:10:17.518Z [WARN] (Copier) myExample: stderr. KeyError: 'AWS_GG_NUCLEUS_DOMAIN_SOCKET_FILEPATH_FOR_COMPONENT'. {scriptName=services.myExample.lifecycle.Run.Script, serviceName=myExample, currentState=RUNNING} 2023-02-10T21:10:17.540Z [INFO] (Copier) myExample: Run script exited. {exitCode=1, serviceName=myExample, currentState=RUNNING}

为什么会报 AWS_GG_NUCLEUS_DOMAIN_SOCKET_FILEPATH_FOR_COMPONENT missing的错误?怎么解决这个问题?P S 使用non-zipped的包的时候我没有这个报错

profile picture
专家
已提问 5 个月前21 查看次数
1 回答
0

【以下的回答经过翻译处理】 你的文件的命令中有sudo,不要使用sudo,这就是RequiresPrivilege的目的。

sudo将删除所有环境变量。 可以改成

  Lifecycle:
    Run:
      RequiresPrivilege: true
      Script: python3 {artifacts:decompressedPath}/example/main.py

profile picture
专家
已回答 5 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则