.adef faultAction: error: Unrecognized section name 'faultAc


#1

Hi

Legato 16-01 WP8548

I tried to use fault action in the .adef file as per latest
http://legato.io/legato-docs/latest/def_files_adef.html#defFilesAdef_processFaultAction

Results in

john@john-ubuntuV2:~/ds201601/workspaceAvmsMqtt/mqttDemo1$ mkapp -t wp85 mqttDemo1.adef ** ERROR: /home/john/ds201601/workspaceAvmsMqtt/mqttDemo1/mqttDemo1.adef:33:11: error: Unrecognized section name 'faultAction'.

Any ideas?

Also

  • is there a way to run (callback?) fault specific code triggered by the faultAction detection?
  • also to run a callback on application stop

Thanks in advance

John


#2

Hi, John,

I suspect the error is because the ‘faultAction: stop’ is being used outside of a ‘processes:’ section. It’s on our “to do” list to make the error messages more helpful in cases like this.

We don’t currently have a callback for shutdown, but you can catch the SIGTERM signal using the Signal API and you can use atexit() to register for a callback when the process exits normally (not due to a signal).

Cheers,

–Jen


#3

Hi Jen

Ah - got it.

I think the reason I got this wrong was - I was in a hurry - I was looking for a solution to the problem of what to do if the app failed.
I was in the middle of trying to fix it and searched the manual.
Found faultAction:
Didn’t back track to the previous heading processes: and assumed that faultAction: was like the other top level defs like start:

Maybe it would help if in the manual’s faultAction: example instead of

there was

processes: { ... faultAction: restart ... }

Downside is the manual gets bigger :frowning:

Notes on .exit type code - the following works

// this function is called when this application stops
static void sig_appTermination_cbh(int sigNum)
{
    LE_INFO("app stopped");
}

COMPONENT_INIT
{
    le_sig_Block(SIGTERM);
    le_sig_SetEventHandler(SIGTERM, sig_appTermination_cbh);
}

Thanks

John