Direkt zum Inhalt

Greengrass V2 Native Component Duplicated

0

I have a native component running in a Greengrass V2 environment. We noticed that we were getting duplicate results after it is sent an MQTT message to do work. If I look on the box I can see that the component seems to be duplicated - running twice.

root@ggc-lnx:/greengrass/v2/logs# ps aux | grep node
root     2298939  0.0  0.0   2892  1004 ?        S    Jan07   0:00 sh -c /usr/bin/nodejs20.x /greengrass/v2/packages/artifacts-unarchived/ggv2-lwc-main-collector-component/3.0.3/ggv2-lwc-main-collector-component/src/index.js
root     2298940  0.0  0.0   2892   952 ?        S    Jan07   0:00 sh -c /usr/bin/nodejs20.x /greengrass/v2/packages/artifacts-unarchived/ggv2-lwc-main-collector-component/3.0.3/ggv2-lwc-main-collector-component/src/index.js
root     2298944  0.0  0.4 11867328 75444 ?      Sl   Jan07   3:09 /usr/bin/nodejs20.x /greengrass/v2/packages/artifacts-unarchived/ggv2-lwc-main-collector-component/3.0.3/ggv2-lwc-main-collector-component/src/index.js
root     2298946  0.0  0.4 11867344 76896 ?      Sl   Jan07   3:03 /usr/bin/nodejs20.x /greengrass/v2/packages/artifacts-unarchived/ggv2-lwc-main-collector-component/3.0.3/ggv2-lwc-main-collector-component/src/index.js
root     3362738  0.0  0.0   9340  5616 ?        S     2024   0:00 sudo -n -E -H -u ggc_user -g #999 -- sh -c /usr/bin/nodejs20.x /greengrass/v2/packages/artifacts-unarchived/ggv2-lwc-ple-component/1.0.4/ggv2-lwc-ple-component/src/index.js
ggc_user 3362741  0.0  0.0   2892   980 ?        S     2024   0:00 sh -c /usr/bin/nodejs20.x /greengrass/v2/packages/artifacts-unarchived/ggv2-lwc-ple-component/1.0.4/ggv2-lwc-ple-component/src/index.js
ggc_user 3362742  0.0  0.5 32587212 87816 ?      Sl    2024   0:03 /usr/bin/nodejs20.x /greengrass/v2/packages/artifacts-unarchived/ggv2-lwc-ple-component/1.0.4/ggv2-lwc-ple-component/src/index.js

You can see that the component called "ggv2-lwc-main-collector-component" is running twice. There is another component called "ggv2-lwc-ple-component" that is running fine.

Is there a reason for this duplication?

gefragt vor 2 Jahren159 Aufrufe

3 Antworten
0

sh -c is creating a child process and when greengrass cleans up the parent process of the component it is not automatically killing the child process.

I suggest you remove sh -c and run the nodejs command directly in your recipe.

AWS

beantwortet vor 2 Jahren

  • But I didn't put that in. This is my lifecycle run script from the recipe

    "Script": "/usr/bin/nodejs20.x {artifacts:decompressedPath}/ggv2-lwc-main-collector-component/src/index.js"

  • What version of Greengrass are you running? We have found an issue with GG v2.14.0 where GG shutdown is not graceful. Please try other versions.

0

The duplication of the "ggv2-lwc-master-collector-component" that you're observing is not typical behavior for AWS IoT Greengrass V2 components. Generally, each component should run as a single instance unless specifically designed to have multiple instances.

There are a few potential reasons for this duplication:

  1. Configuration Issue: The component's recipe might be configured to run multiple instances. Check the component's recipe file for any settings that could cause it to launch multiple processes.

  2. Deployment Problem: There might have been an issue during deployment that caused the component to be started multiple times. This could happen if there were interruptions or errors during the deployment process.

  3. Component Logic: The component itself might be designed to spawn multiple processes. This could be intentional, but if it's not, there might be a bug in the component's code causing it to start additional instances of itself.

  4. Restart Without Cleanup: If the Greengrass core was restarted abruptly or if there was a system crash, it's possible that the old process wasn't properly terminated before a new one was started.

To resolve this issue:

  1. Review the component's recipe and configuration to ensure it's not set to run multiple instances.

  2. Check the Greengrass logs for any errors or warnings related to this component.

  3. Try redeploying the component or restarting the Greengrass core software.

  4. If the problem persists, you may need to manually stop the extra processes and then redeploy the component.

  5. Consider reaching out to AWS support if you can't resolve the issue, as this behavior is not expected for standard Greengrass V2 components.
    Sources
    How do I redeploy the same deployment config in Greengrass v2 | AWS re:Post
    How to make a greengrass component run only once? | AWS re:Post
    Greengrass Core V2 - Restart component on config change | AWS re:Post

beantwortet vor 2 Jahren

0

This appears to be an issue related to https://github.com/aws-greengrass/aws-greengrass-nucleus/blob/main/README_SYSTEMD_GUIDANCE.md , that link contains guidance to work around the issue.

We have also released version 2.14.1 which resolves this issue.

AWS

beantwortet vor 2 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.