Skip to content

How do I get Greengrass Lite Components to startup at boot time

0

I have an embedded linux device with greengrass lite running on it.

I am taking meta-aws from the Scarthgap branch at commit 68470b8f from October 8th.

It is working well - fleet provisioning is running and I have devices that automatically provision themselves into a thing group.

I am learning how to make components and deploy them to this group. I have a simple component binary that I have deployed, and it works fine when it is initially deployed, but it does not start up again when the device reboots.

My component recipe is as follows:

{
  "RecipeFormatVersion": "2020-01-25",
  "ComponentName": "com.rho.demo-app",
  "ComponentVersion": "1.0.6",
  "ComponentDescription": "RHO Demo App - Basic MQTT Publisher",
  "ComponentPublisher": "Sensoteq",
  "ComponentConfiguration": {
    "DefaultConfiguration": {
      "Debug": false
    }
  },
  "Manifests": [
    {
      "Platform": {
        "os": "linux",
        "architecture": "aarch64",
        "runtime": "aws_nucleus_lite"
      },
      "Lifecycle": {
        "install": {
          "Script": "chmod +x {artifacts:path}/rho-demo-app",
          "RequiresPrivilege": true
        },
        "run": {
          "Script": "{artifacts:path}/rho-demo-app",
          "RequiresPrivilege": false
        }
      },
      "Artifacts": [
        {
          "Uri": "s3://rho-greengrass-components/rho-demo-app",
          "Digest": "c0ee8796df3d4ba844cfff0f7085b6341451efcfef030714d5343d75d8e4e81b",
          "Algorithm": "SHA-256",
          "Unarchive": "NONE",
          "Permission": {
            "Execute": "OWNER"
          }
        }
      ]
    }
  ]
}

This deploys to my device and a systemd service is created for it:

[Unit]
StartLimitInterval=3600
StartLimitBurst=3
Description=RHO Demo App - Basic MQTT Publisher
PartOf=greengrass-lite.target
Wants=ggl.core.ggipcd.service
After=ggl.core.ggipcd.service

[Service]
Restart=on-failure
RestartSec=1
WorkingDirectory=/var/lib/greengrass/work/com.rho.demo-app
Environment="AWS_GG_NUCLEUS_DOMAIN_SOCKET_FILEPATH_FOR_COMPONENT=/var/lib/greengrass/gg-ipc.socket"
Type=exec
ExecStart=/usr/bin/recipe-runner -n com.rho.demo-app -v 1.0.6 -p run
SyslogIdentifier=com.rho.demo-app
TimeoutSec=120
User=ggcore
Group=ggcore

[Install]
WantedBy=greengrass-lite.target

When it is deployed, it runs perfectly, the deployment returns as Succeeded in the console and I can see logs from my demo app:

# journalctl -u ggl.com.rho.demo-app.service -f
Oct 22 13:56:03 rho-device-838a141c com.rho.demo-app[729]: 2025-10-22T13:56:03Z INF Publishing message count=42 topic=$aws/things/rho-device-838a141c/debugtx
Oct 22 13:56:03 rho-device-838a141c com.rho.demo-app[729]: 2025-10-22T13:56:03Z INF ✓ Message published successfully
Oct 22 13:56:08 rho-device-838a141c com.rho.demo-app[729]: 2025-10-22T13:56:08Z INF Publishing message count=43 topic=$aws/things/rho-device-838a141c/debugtx
Oct 22 13:56:08 rho-device-838a141c com.rho.demo-app[729]: 2025-10-22T13:56:08Z INF ✓ Message published successfully
Oct 22 13:56:13 rho-device-838a141c com.rho.demo-app[729]: 2025-10-22T13:56:13Z INF Publishing message count=44 topic=$aws/things/rho-device-838a141c/debugtx
Oct 22 13:56:13 rho-device-838a141c com.rho.demo-app[729]: 2025-10-22T13:56:13Z INF ✓ Message published successfully
Oct 22 13:56:18 rho-device-838a141c com.rho.demo-app[729]: 2025-10-22T13:56:18Z INF Publishing message count=45 topic=$aws/things/rho-device-838a141c/debugtx
Oct 22 13:56:18 rho-device-838a141c com.rho.demo-app[729]: 2025-10-22T13:56:18Z INF ✓ Message published successfully
Oct 22 13:56:23 rho-device-838a141c com.rho.demo-app[729]: 2025-10-22T13:56:23Z INF Publishing message count=46 topic=$aws/things/rho-device-838a141c/debugtx
Oct 22 13:56:23 rho-device-838a141c com.rho.demo-app[729]: 2025-10-22T13:56:23Z INF ✓ Message published successfully
Oct 22 13:56:28 rho-device-838a141c com.rho.demo-app[729]: 2025-10-22T13:56:28Z INF Publishing message count=47 topic=$aws/things/rho-device-838a141c/debugtx
Oct 22 13:56:28 rho-device-838a141c com.rho.demo-app[729]: 2025-10-22T13:56:28Z INF ✓ Message published successfully

What I can't understand is why this does not start up again when the device reboots. Is there something critical missing from the lifecycle section of my recipe? I've checked the reference but nothing is jumping out at me.

The installed service suggests:

Wants=ggl.core.ggipcd.service
After=ggl.core.ggipcd.service

And this service is running fine.

  • After rebooting, is Greengrass running? The recipe looks fine and I'd expect the component to be started when rebooting.

    On a side note, I don't think you need the install step as you have execute permissions on the artifact. Was the component not working without this step?

  • @PatrickZ-AWS yes greengrass is running. Regards the install step, I think I was just trying to be smarter than I am, I see how it's meaningless with the EXECUTE step

  • I saw from the other comment that you were going to retry with a fresh device--were you seeing the same behavior there or has the issue been resolved?

  • Sorry @PatrickZ-AWS - been on a few days vacation, going to try this in the next 24 hours so will feed back.

    From the comment below, I think I need to use startup instead of run.

    "Use startup to run a command that must exit successfully or update the component's status to RUNNING before dependent components can start. Use the UpdateState IPC operation to set the component's status to RUNNING or ERRORED when the component starts a script that doesn't exit. "

    As I am running a binary that does not exit, I either need to add a startup script that exits or use the UpdateState IPC operation. I will look into the latter.

  • @PatrickZ-AWS - is there a reference for the IPC? I am using Golang and I don't see SDK support for that.

asked 10 months ago194 views

2 Answers
1
Accepted Answer

As with many of these things, this was human error on my behalf.

I have an overlay on systemd so that I can keep my rootfs read only and store the greengrass systemd unit symlinks on a data partition so they survive OS updates.

This overlay was loading later than greengrass-lite.target, therefore it did not see the component unit at boot time.

I've fixed the timing of my overlay to run before greengrass-lite.target and things seem to be behaving now.

Apologies for the noise!

answered 9 months ago

0

To ensure your Greengrass v2 component starts automatically at boot time, you need to modify your component recipe to include a startup lifecycle step rather than just a run step.

In AWS IoT Greengrass v2, the startup lifecycle is specifically designed for processes that need to start when the component starts and must exit successfully (or update their status to RUNNING) before dependent components can start. The startup step is what ensures your component starts automatically at boot time.

Here's how you should modify your component recipe:

{
"RecipeFormatVersion": "2020-01-25",
"ComponentName": "com.rho.demo-app",
"ComponentVersion": "1.0.6",
"ComponentDescription": "RHO Demo App - Basic MQTT Publisher",
"ComponentPublisher": "Sensoteq",
"ComponentConfiguration": {
"DefaultConfiguration": {
"Debug": false
}
},
"Manifests": [
{
"Platform": {
"os": "linux",
"architecture": "aarch64",
"runtime": "aws_nucleus_lite"
},
"Lifecycle": {
"install": {
"Script": "chmod +x {artifacts:path}/rho-demo-app",
"RequiresPrivilege": true
},
"startup": {
"Script": "{artifacts:path}/rho-demo-app",
"RequiresPrivilege": false
}
},
"Artifacts": [
{
"Uri": "s3://rho-greengrass-components/rho-demo-app",
"Digest": "c0ee8796df3d4ba844cfff0f7085b6341451efcfef030714d5343d75d8e4e81b",
"Algorithm": "SHA-256",
"Unarchive": "NONE",
"Permission": {
"Execute": "OWNER"
}
}
]
}
]
}

The key change is replacing the run lifecycle step with a startup lifecycle step. This tells Greengrass to start your component when the Greengrass core starts, including at system boot.

After making this change, create a new version of your component and deploy it to your device. Your component should then start automatically when the device boots up.
Sources
AWS IoT Greengrass component recipe reference - AWS IoT Greengrass

answered 10 months ago

  • Hi - thanks for your response.

    I tried startup before, and I ran into an issue where the deployment always said "In Progress" and never moved to "Succeeded" and also, I found that the component did not start on a reboot.

    That said, I was working quickly so I will go back to the start and try it again on a clean device.

  • Ok - I switched to using startup as you suggested.

          "Lifecycle": {
            "startup": "{artifacts:path}/rho-demo-app"
          },
    

    As before, this runs, but the deployment eventually fails:

    Oct 30 17:23:38 rho-device-5d704731 ggdeploymentd[470]: E[ggdeploymentd] deployment_handler.c:2248: com.rho.demo-app is broken.
    Oct 30 17:23:38 rho-device-5d704731 ggdeploymentd[470]: E[ggdeploymentd] deployment_handler.c:2343: Failed waiting for com.rho.demo-app
    Oct 30 17:23:38 rho-device-5d704731 ggdeploymentd[470]: W[ggdeploymentd] deployment_handler.c:3355: Completed deployment processing and reporting job as FAILED.
    Oct 30 17:23:38 rho-device-5d704731 ggdeploymentd[470]: I[ggdeploymentd] iot_jobs_listener.c:172: Got message from IoT Core; topic: $aws/things/rho-device-5d704731/jobs/notify-next-namespace-aws-gg-deployment, payload: {"timestamp":1761845018}. 
    
  • Also, I noticed that while my binary is running, the service always stays in the activating state:

    # systemctl status ggl.com.rho.demo-app.service
    * ggl.com.rho.demo-app.service - RHO Demo App
         Loaded: loaded (/etc/systemd/system/ggl.com.rho.demo-app.service; enabled; preset: disabled)
         Active: activating (start) since Thu 2025-10-30 17:21:35 UTC; 1min 48s ago
       Main PID: 759 (5)
          Tasks: 10 (limit: 466)
         Memory: 6.9M (peak: 7.6M)
            CPU: 219ms
         CGroup: /system.slice/ggl.com.rho.demo-app.service
                 |-759 /bin/sh /dev/fd/5
                 `-761 /var/lib/greengrass/packages/artifacts/com.rho.demo-app/1.0.9//rho-demo-app
    

    systemd restarts it every few mins.

    Do I need to report my status via IPC for this to work? Or do I need to give my recipe permissions so that the recipe runner can do that for me?

    Is there an example of a similar component with restart that you know of?

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.