{= # # # start_process_logs.cfv # # include "templates.util.base_util"; include "templates.util.rbac.rbac_util"; include "templates.util.encoding"; include "templates.util.database"; debug_message("\n#### start_update_database.cfv START \n\n"); string session_id = volatile.session_id; string profile_name = internal.profile_name; bool is_root_admin = get_is_root_admin(); string page_token = v.fp.page_token; string output_file = v.fp.output_file; if ((is_root_admin or get_config_feature_permission(session_id, profile_name, "process_logs", "view")) and get_is_valid_page_token(session_id, "process_logs", page_token)) then ( # debug_message("\n" . node_as_string("v.fp") . "\n"); string error_message; string task_id; # # # Make sure that no snapon operation is active and that the database isn't already building. # # bool is_active_snapon_operation = get_is_active_snapon_operation(profile_name); if (!is_active_snapon_operation) then ( # # # get database info # # node db_info = get_database_info(profile_name, true); debug_message("#### start_process_logs.cfv - database_info:\n" . node_as_string(db_info) . "\n"); # # # Get database_is_building # # bool database_is_building = get_database_is_building(profile_name, db_info); debug_message("#### start_process_logs.cfv - database_is_building: " . database_is_building . "\n"); # # # Start process_logs # # if (!database_is_building) then ( delete_node("volatile.options"); volatile.options.1 = "background"; volatile.options.2 = "-p"; volatile.options.3 = profile_name; volatile.options.4 = "-a"; volatile.options.5 = "pl"; # volatile.options.6 = "-v"; # volatile.options.7 = "e"; if (output_file ne "") then ( volatile.options.6 = "-v"; volatile.options.7 = "e > " . output_file; ) else ( volatile.options.6 = "-v"; volatile.options.7 = "e"; ); debug_message("\n" . node_as_string("volatile.options") . "\n"); debug_message("#### start_process_logs.cfv via exec() \n"); task_id = exec("", "volatile.options", false); # In the case that process_logs doesn't start immediately # wait for maximum 10 seconds for an active task before we check # for progress on the client side. bool is_active_task = false; int check_for_active_task_count = 0; # debug_message("#### start_update_database.cfv - is_active_task: " . is_active_task . "\n"); node task_info = new_node(); node task_item = new_node(); while (!is_active_task and (check_for_active_task_count < 20)) ( sleep_milliseconds(500); task_info = get_task_info(); # debug_message(node_as_string(task_info)); if (task_info?{task_id}) then ( task_item = task_info{task_id}; is_active_task = (task_item?{"active"} and @task_item{"active"}); ); # Clean up delete_node(task_info); check_for_active_task_count++; ); # debug_message("#### start_update_database.cfv - is_active_task: " . is_active_task . "\n"); # debug_message("#### start_update_database.cfv - check_for_active_task_count: " . check_for_active_task_count . "\n"); # # # If the task reports an error then show the error message # # if (task_item?{"error_message"} and (@task_item{"error_message"} ne "")) then ( error_message = @task_item{"error_message"}; error(error_message); ); ) else ( # A database operation is active, can't process logs error_message = lang_admin.process_logs.database_operation_active; ); # Clean up delete_node(db_info); ) else ( # A snapon operation is active, can't process logs error_message = lang_admin.process_logs.snapon_operation_active; ); # # # Send response # # string dat = "{"; dat .= add_json("taskId", task_id, "string"); dat .= add_json("errorMessage", error_message, "string"); dat = close_json(dat); debug_message("#### dat:\n" . dat . "\n"); "processLogs.startProcessLogsResponse(" . dat . ")\n"; ) else ( # No permission to access this resource (URL) display_no_permission_html(); ); =}