if error_msg: logger.error(error_msg) exit() # Signals signal(SIGINT, signal_handler) signal(SIGTERM, signal_handler) # Check if it is already running if status()['wazuh-clusterd'] == 'running': clean_exit(reason="wazuh_clusterd is already running", error=True) # Foreground/Daemon if not args.f: res_code = pyDaemon() # Get cluster config try: cluster_config = read_config() except WazuhException as e: clean_exit(reason=str(e), error=True) if not cluster_config or cluster_config['disabled'] == 'yes': clean_exit(reason="Cluster disabled", error=True) # Drop privileges to ossec if not args.r: setgid(common.ossec_gid) seteuid(common.ossec_uid)
cluster_items = cluster.get_cluster_items() try: cluster.check_cluster_config(cluster_configuration) except Exception as e: main_logger.error(e) sys.exit(1) if args.test_config: sys.exit(0) # clean cluster.clean_up() # Foreground/Daemon if not args.foreground: pyDaemonModule.pyDaemon() # Drop privileges to ossec if not args.root: os.setgid(common.ossec_gid) os.setuid(common.ossec_uid) pyDaemonModule.create_pid('wazuh-clusterd', os.getpid()) main_function = master_main if cluster_configuration[ 'node_type'] == 'master' else worker_main try: asyncio.run( main_function(args, cluster_configuration, cluster_items, main_logger)) except KeyboardInterrupt: