#define controller_string_fifo "fifo"
#define controller_string_freeze "freeze"
#define controller_string_fsize "fsize"
+ #define controller_string_full_path "full_path"
#define controller_string_group "group"
#define controller_string_groups "groups"
#define controller_string_how "how"
#define controller_string_wait "wait"
#define controller_string_want "want"
#define controller_string_wish "wish"
+ #define controller_string_with "with"
#define controller_string_yes "yes"
#define controller_string_action_length 6
#define controller_string_fifo_length 4
#define controller_string_freeze_length 6
#define controller_string_fsize_length 5
+ #define controller_string_full_path_length 9
#define controller_string_group_length 5
#define controller_string_how_length 3
#define controller_string_idle_length 4
#define controller_string_wait_length 4
#define controller_string_want_length 4
#define controller_string_wish_length 4
+ #define controller_string_with_length 4
#define controller_string_yes_length 3
const static f_string_t controller_string_action_s = controller_string_action;
const static f_string_t controller_string_fifo_s = controller_string_fifo;
const static f_string_t controller_string_freeze_s = controller_string_freeze;
const static f_string_t controller_string_fsize_s = controller_string_fsize;
+ const static f_string_t controller_string_full_path_s = controller_string_full_path;
const static f_string_t controller_string_group_s = controller_string_group;
const static f_string_t controller_string_groups_s = controller_string_groups;
const static f_string_t controller_string_how_s = controller_string_how;
const static f_string_t controller_string_wait_s = controller_string_wait;
const static f_string_t controller_string_want_s = controller_string_want;
const static f_string_t controller_string_wish_s = controller_string_wish;
+ const static f_string_t controller_string_with_s = controller_string_with;
const static f_string_t controller_string_yes_s = controller_string_yes;
#endif // _di_controller_string_
controller_rule_action_type_thaw,
controller_rule_action_type_use,
controller_rule_action_type_user,
+ controller_rule_action_type_with,
};
typedef struct {
buffer.string = controller_string_user_s;
buffer.used = controller_string_user_length;
break;
+
+ case controller_rule_action_type_with:
+ buffer.string = controller_string_with_s;
+ buffer.used = controller_string_with_length;
+ break;
}
buffer.size = buffer.used;
f_string_dynamic_t *pid_file = 0;
uint8_t pid_type = 0;
+ bool with_full_path = F_false;
+
// child processes should receive all signals and handle the signals as they see fit.
f_signal_how_t signals = f_signal_how_t_initialize;
f_signal_set_empty(&signals.block);
if (process->rule.items.array[i].type == controller_rule_item_type_setting) continue;
+ with_full_path = F_false;
+
+ for (j = 0; j < process->rule.items.array[i].actions.used; ++j) {
+
+ if (process->rule.items.array[i].actions.array[j].type == controller_rule_action_type_with) {
+ for (k = 0; k < process->rule.items.array[i].actions.array[j].parameters.used; ++k) {
+
+ if (fl_string_dynamic_compare_string(controller_string_full_path_s, process->rule.items.array[i].actions.array[j].parameters.array[k], controller_string_full_path_length) == F_equal_to) {
+ with_full_path = F_true;
+
+ break;
+ }
+ } // for
+
+ if (with_full_path) break;
+ }
+ } // for
+
for (j = 0; j < process->rule.items.array[i].actions.used; ++j) {
if (!main.thread->enabled) {
execute_set.parameter.data = 0;
execute_set.parameter.option = fl_execute_parameter_option_threadsafe | fl_execute_parameter_option_return;
- if (process->rule.items.array[i].type == controller_rule_item_type_command) {
-
- if (strchr(process->rule.items.array[i].actions.array[j].parameters.array[0].string, f_path_separator_s[0])) {
- execute_set.parameter.option |= fl_execute_parameter_option_path;
- }
+ if (with_full_path) {
+ execute_set.parameter.option |= fl_execute_parameter_option_path;
+ }
+ if (process->rule.items.array[i].type == controller_rule_item_type_command) {
status = controller_rule_execute_foreground(process->rule.items.array[i].type, process->rule.items.array[i].actions.array[j], 0, process->rule.items.array[i].actions.array[j].parameters, options, main, &execute_set, process);
if (status == F_child || status == F_signal || F_status_set_fine(status) == F_lock) break;
}
}
else if (process->rule.items.array[i].type == controller_rule_item_type_script) {
-
execute_set.parameter.data = &process->rule.items.array[i].actions.array[j].parameters.array[0];
- if (process->rule.script.used && strchr(process->rule.script.string, f_path_separator_s[0])) {
- execute_set.parameter.option |= fl_execute_parameter_option_path;
- }
-
status = controller_rule_execute_foreground(process->rule.items.array[i].type, process->rule.items.array[i].actions.array[j], process->rule.script.used ? process->rule.script.string : controller_default_program_script, arguments_none, options, main, &execute_set, process);
if (status == F_child || status == F_signal || F_status_set_fine(status) == F_lock) break;
}
}
else if (process->rule.items.array[i].type == controller_rule_item_type_service) {
-
pid_file = 0;
pid_type = 0;
} // for
if (pid_file) {
- if (strchr(process->rule.items.array[i].actions.array[j].parameters.array[0].string, f_path_separator_s[0])) {
- execute_set.parameter.option |= fl_execute_parameter_option_path;
- }
-
status = controller_rule_execute_pid_with(pid_file, pid_type, process->rule.items.array[i].type, process->rule.items.array[i].actions.array[j], 0, process->rule.items.array[i].actions.array[j].parameters, options, main, &execute_set, process);
if (status == F_child || status == F_signal || F_status_set_fine(status) == F_lock) break;
}
}
else if (process->rule.items.array[i].type == controller_rule_item_type_utility) {
-
pid_file = 0;
pid_type = 0;
if (pid_file) {
execute_set.parameter.data = &process->rule.items.array[i].actions.array[j].parameters.array[0];
- if (process->rule.script.used && strchr(process->rule.script.string, f_path_separator_s[0])) {
- execute_set.parameter.option |= fl_execute_parameter_option_path;
- }
-
status = controller_rule_execute_pid_with(pid_file, pid_type, process->rule.items.array[i].type, process->rule.items.array[i].actions.array[j], process->rule.script.used ? process->rule.script.string : controller_default_program_script, arguments_none, options, main, &execute_set, process);
if (status == F_child || status == F_signal || F_status_set_fine(status) == F_lock) break;
if (!WIFEXITED(result)) {
status = F_status_set_error(F_failure);
}
+
+ // @fixme needs a custom option to desginate what is an error.
}
else {
if (!main.thread->enabled) {
else if (fl_string_dynamic_compare_string(controller_string_user_s, cache->action.name_action, controller_string_user_length) == F_equal_to) {
type = controller_rule_action_type_user;
}
+ else if (fl_string_dynamic_compare_string(controller_string_with_s, cache->action.name_action, controller_string_with_length) == F_equal_to) {
+ type = controller_rule_action_type_with;
+ }
else {
if (main.data->warning.verbosity == f_console_verbosity_debug) {
f_thread_mutex_lock(&main.thread->lock.print);
}
if ((process->options & controller_process_option_simulate) && main.data->parameters[controller_parameter_validate].result == f_console_result_found) {
- controller_rule_validate(process->rule, controller_rule_action_type_start, process->options, main, &process->cache);
+ controller_rule_validate(process->rule, action, process->options, main, &process->cache);
}
f_array_length_t i = 0;
}
// synchronously execute dependency.
- status = controller_rule_process_begin(0, alias_other, controller_rule_action_type_start, options_process, process->stack, main, process_other->cache);
+ status = controller_rule_process_begin(0, alias_other, action, options_process, process->stack, main, process_other->cache);
if (status == F_child || status == F_signal) {
f_thread_unlock(&process_other->active);
}
if (F_status_is_error_not(status)) {
+ // @todo this needs to support passing different (supported) types, particularly when the "control" is written, (an entry will always send start and an exit will always send stop).
status = controller_rule_process(controller_rule_action_type_start, main, process);
}
}
"want": Two Content, the first being a partial path and the second being a rule file name without extension (such as "boot" "modules").
"wish": Two Content, the first being a partial path and the second being a rule file name without extension (such as "boot" "modules").
- The "service" and "utility" Rule Types allow the following the FSS-0001 (Extended)\:
- "create": One Content representing the path to a PID file.
- "use": One Content representing the path to a PID file.
-
The "command" and "script" Rule Types allow the following the FSS-0001 (Extended)\:
"kill": One or more Content representing a program being executed and its arguments.
"pause": One or more Content representing a program being executed and its arguments.
"resume": One or more Content representing a program being executed and its arguments.
"start": One or more Content representing a program being executed and its arguments.
"stop": One or more Content representing a program being executed and its arguments.
+ "with": One or more Content representing special options for the Rule Type.
+
+ The "service" and "utility" Rule Types allow the following the FSS-0001 (Extended)\:
+ "create": One Content representing the path to a PID file.
+ "use": One Content representing the path to a PID file.
+ "with": One or more Content representing special options for the Rule Type.
The "command" and "service" Rule Types allow the following the FSS-0003 (Extended List)\:
"kill": A list repesenting multiple programs and their respective arguments to execute.