Strategy for determining first run of a workflow on boot up

sql
sql-node
sqlite
#1

Hi

I am trying to think of a strategy to determine if a workflow is running for the first time on bootup of an Edge device.

If workflow storage variables are persistent across reboots (which I hope is the case - see my other question just asked), then can you suggest a strategy for determining this.

There two different conditions to - I think.

  1. Host has booted and agent started.
  2. Host has been running, but agent restarted for whatever reason.

Thanks

Tim

1 Like

#2

We are actually planning to address this directly in the agent, by providing a “Edge Agent Startup” trigger - which would trigger when the agent starts up. I’ll add a ‘+1’ to that ticket, since it sounds like that would be useful to you! Until then, though, this is a harder problem. You might be able to access system uptime using the process exec node (I have not tried this). Edge workflows also have access to environment variables - so you might be able to set it up so when the agent starts, there is an environment variable with the agent start time. I’ll discuss internally, and see if there are other options at the moment as well.

0 Likes

#3

Probably best strategy at the moment is use workflow variable that has datetime of last update.
On workflows that run frequently I can check last run, and if it’s more than a few minutes I can at least say, this workflow that runs every 10 secs hasn’t run, so system has been down or broken (same thing :wink:

0 Likes

#4

Hi @Michael_Kuehl, is this feature addition was addressed somehow? I would like to trigger a flow in an Agent Workflow every time when it reboots (edge device reboot, new docker image run, new workflow version deployment etc.

Particularly, I need to read meta data of peripheral devices such as serial numbers, firmware versions etc and send it to the cloud. Another goal is to request initial agent configuration settings from the cloud on reboot. I tried to use Get/Set Value nodes, but it looks like Agent remembers value state after reboot (deployment of new workflow version). Use an agent running time from the last reboot could be used for this purpose, but I am not sure how to bring it inside workflow.

Please advice

0 Likes

#5

Hi @Alexander_Kondrov,

One of our engineers recommended using an in-memory SQLite database (which will be saved in memory and not file based). Then, using a Timer, you could check for a flag of some sort, and if it is not there, you will know the container restarted.

SQLite documentation and configuration for in-memory databases can be found here. Losant documentation for the SQL Node contains some information on in-memory connection configuration, which can be found here.

Let me know if I can help further!
Julia

1 Like