diff --git a/app/models/miq_server/at_startup.rb b/app/models/miq_server/at_startup.rb index aff55b05ccf..6761e063060 100644 --- a/app/models/miq_server/at_startup.rb +++ b/app/models/miq_server/at_startup.rb @@ -5,6 +5,7 @@ module MiqServer::AtStartup module ClassMethods def startup! log_managed_entities + write_systemd_service_files if MiqEnvironment::Command.supports_systemd? clean_all_workers clean_dequeued_messages purge_report_results @@ -17,6 +18,16 @@ def log_managed_entities log_not_under_management(prefix) end + def write_systemd_service_files + MiqWorkerType.worker_class_names.each do |class_name| + worker_klass = class_name.safe_constantize + worker_klass.ensure_systemd_files if worker_klass&.systemd_worker? + rescue => err + _log.warn("Failed to write systemd service files: #{err}") + _log.log_backtrace(err) + end + end + # Delete and Kill all workers that were running previously def clean_all_workers _log.info("Cleaning up all workers...") diff --git a/app/models/miq_worker/systemd_common.rb b/app/models/miq_worker/systemd_common.rb index c09730a3a03..292460caedb 100644 --- a/app/models/miq_worker/systemd_common.rb +++ b/app/models/miq_worker/systemd_common.rb @@ -12,8 +12,8 @@ def supports_systemd? end def ensure_systemd_files - target_file_path.write(target_file) unless target_file_path.exist? - service_file_path.write(unit_file) unless service_file_path.exist? + target_file_path.write(target_file) + service_file_path.write(unit_file) end def service_base_name