Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/ham_en/ham/hamapi/ham_action_restart.html on line 1
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/ham_en/ham/hamapi/ham_action_restart.html on line 1
Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/ham_en/ham/hamapi/ham_action_restart.html on line 8
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/ham_en/ham/hamapi/ham_action_restart.html on line 8
Add a restart action to a condition
#include <ha/ham.h>
ham_action_t *ham_action_restart( ham_condition_t *chdl,
const char *aname,
const char *path,
unsigned flags);
libham
You use the ham_action_restart() function to add an
action (aname) to a given condition. In this case,
the action will restart a program that has died.
|
Restart actions can be associated only with death conditions
(CONDDEATH).
Note also that there can be only one restart action over all
the death conditions in an entity. |
The handle (chdl) is obtained either:
- from one of the ham_condition*() functions to add conditions
or:
- by calling any of the ham_condition_handle() functions
to request a handle to a specific condition.
You use the path parameter to specify the external program
or command line to be executed — path must contain the FULL
path to the executable along with all parameters to be passed
to it.
along with all parameters to be passed to it. If either the pathname or the
arguments contain spaces that need to be passed on literally to the spawn
call,
they need to be quoted. As long as the subcomponents within the
path arguments
are quoted, using either of the following methods:
\'path with space\'
or
\"path with space\",
the following is allowed:
"\'path with space\' arg1 arg2 \"arg3 with space\"".
This would be parsed as
"path with space" -> path
arg1 = arg1
arg2 = arg2
arg3 = "arg3 with space".
The command line is in turn passed onto a spawn command
by the HAM to create a new process that will execute the command.
The action is executed when the appropriate condition is
triggered.
Note that this action also triggers a restart
condition in the entity.
Currently the following flags are defined:
- HREARMAFTERRESTART
- Indicates that the action is to be automatically rearmed
after the entity that it belongs to is restarted. By
default, this flag is disabled — actions automatically
get pruned across restarts of the entity. Note that if the
condition that this action belongs to is pruned after a
restart, this action will also be removed, regardless of the
value of this flag.
- HACTIONBREAKONFAIL
- Indicates that if this action were to fail,
and it is part of a list of actions, none of the actions following
this one in the list of actions will be executed.
- HACTIONKEEPONFAIL
- Indicates that the action will be retained even if it
fails. The default behavior is to remove failed actions. Nevertheless
if the condition that this action is associated with is not retained,
the action will get automatically removed.
Users can specify what will be done if an action fails. By adding
action fail actions to a list associated with an action, users
can determine what will be done in the case of an action failure. For
every action that fails, the corresponding action fail list will be
executed. Certain actions (e.g. ham_action_log() and
ham_action_heartbeat_healthy()) never fail. For more details,
refer to the appropriate section in the HAM API reference
for the ham_action_fail_*() calls.
A valid handle to an action in a condition, or NULL if an error
occurred (errno is set).
- EBADF
- Couldn't connect to the HAM.
- EINVAL
- The name given in aname is invalid (e.g. it
contains the “/” character) or is NULL.
The connection to the HAM is invalid. This happens when the
process that opened the connection (using ham_connect())
and the process that's calling ham_action_restart() aren't the same.
- ENAMETOOLONG
- The name given (in aname) is too long, i.e.
it exceeds _POSIX_PATH_MAX (defined in <limits.h>).
Note that the combined length of an entity/condition/action
name is also limited by _POSIX_PATH_MAX.
- ENOENT
- There's no entity or condition specified by the given
handle (chdl).
- ENOMEM
- Not enough memory to create a new handle.
In addition to the above errors, the HAM returns any error
it encounters while servicing this request.
QNX Neutrino
Safety: | |
Cancellation point |
No |
Interrupt handler |
No |
Signal handler |
No |
Thread |
Yes |
ham_action_execute(),
ham_action_notify_pulse(),
ham_action_notify_signal(),
ham_action_remove(),
ham_action_waitfor(),
ham_condition(),
ham_condition_handle()
Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/ham_en/ham/hamapi/ham_action_restart.html on line 259
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/ham_en/ham/hamapi/ham_action_restart.html on line 259