Lightact Manager can manage other Apps besides Lightact. This means that if they stop working, it launches them again.
In order for this to work that 3rd party App has to write its heartbeat string to Windows shared memory. The string should be in the following format:
{"tick":"n"}
As you can see it is in JSON format where the key is the tick and the value n is an integer number. This number should be different every time Lightact Manager reads it. Lightact UE4 plugin uses a formula which translates current time into an ever-changing integer number, but technically, as long as it’s a different number, Lightact Manager will assume the app is still running.
Manager reads this heartbeat string with the same frequency it is monitoring Lightact (see Lightact Manager user guide if you don’t know how this frequency is specified). Every time it reads the heartbeat string, it compares whether n integer number value in the heartbeat changed from the last time it read it. If it is the same, it means the app is not working and it should be launched again.
Managing Unreal Engine Games
In this chapter, we’ll explain how you can set an Unreal Engine project to write its heartbeat to a Windows shared memory using Lightact UE4 plugin. If you are using or building a different application it is up to you to make sure the heartbeat is correctly written into the app.
The first step is to click on the Add App button in the Installation tab of Lightact Manager.
You’ll see an additional section pop up. Click on the Browse button and find the executable of your app.
Then type in the name of the Windows shared memory Handle. If you don’t know what to type in, just type UE4Tick (you’ll see why in a bit). Timeout property determines how long after Manager has launched the App, it should wait before starting to check its correct operation again. This is useful when the app takes some time to load. If Manager would start checking its correct operation too soon after it launched it, the app wouldn’t have the time to write its heartbeat into the shared memory yet. This would cause Manager to try to launch it again.
In the Additional Args, you can type-in additional command line arguments.
[vc_message]Using correct command-line arguments, it is possible to launch Unreal Engine project (.uproject file) without launching the Unreal Editor itself. This eliminates the need to package Unreal Engine game before being able to use it with Lightact Manager. For detailed instruction refer to Unreal Engine documentation or ask on our Answerhub and we’ll try to find an answer for you.[/vc_message]
Setting up Unreal Engine
In our Lightact UE4 plugin we’ve created a few nodes that help you generate proper heartbeats.
As 1 second is the smallest interval Manager can possibly check for the correct operation of the app we’ve inserted a Delay node into the Blueprint. It is not strictly necessary to use it though. The other 3 important nodes in the above Blueprint are:
Lightact Tick
This node creates an integer reflecting current system time. The formula is:
current_seconds + 60 * current_minutes + 3600 * current_hours
As we mentioned before, it is not strictly necessary to use this formula as Manager only checks if the value is different every time it reads shared memory.
Make Map
This node combines this into a Map of Strings to Strings.
Write to a shared memory
This node writes this Map to a shared memory under the Handle Name.
[vc_message]Please note that Handle Name in the Write to shared memory node in Unreal Engine has to match the Handle name you type in Lightact Manager. As for the Handle Size, you can enter 64.[/vc_message]