diff --git a/bin/linspector b/bin/linspector index 092dfb5..6f4f5a5 100755 --- a/bin/linspector +++ b/bin/linspector @@ -34,7 +34,7 @@ from linspector.core.monitors import Monitors # i currently only increase the 3rd number because the goal is that 0.19 will become the first # stable version. -__version__ = '0.19.21.dev1' +__version__ = '0.19.22.dev1' __author__ = 'Johannes Findeisen ' logger = logging.getLogger('linspector') diff --git a/etc/linspector.conf b/etc/linspector.conf index 09e0001..7ac01da 100644 --- a/etc/linspector.conf +++ b/etc/linspector.conf @@ -23,6 +23,12 @@ run_mode = cron members = superadmin@example.com,developers@example.com ; scheduler configuration start_scheduler = true +; the mode the scheduler should run. options are, process or thread. default is the thread mode. process mode will run +; multiple processes, thread mode will run only one process with multiple threads. maybe this can be combined to run +; multiple processes with multiple threads... dont know this actually but reading the APScheduler documentation will +; explain this.... :) default is "thread" but Linspector will only run on one CPU core then. default threads are 1024 +; but this can be set much higher here. +scheduler_mode = process max_threads = 3500 ; i recommend to set this to your number of cpu cores available when running on a dedicated linspector host. but if the ; system is running other services you should lower this value when you have too high cpu load. diff --git a/linspector/core/configuration.py b/linspector/core/configuration.py index becfb9e..1d57447 100644 --- a/linspector/core/configuration.py +++ b/linspector/core/configuration.py @@ -25,7 +25,7 @@ class Configuration: self.__configuration.read(configuration_path + '/linspector.conf', 'utf-8') except Exception as err: raise Exception('something went wrong reading the configuration file ' - 'linspector.ini in the configuration root path! ({0})'.format(err)) + 'linspector.conf in the configuration root path! ({0})'.format(err)) else: raise FileNotFoundError("configuration file linspector.ini not found in configuration " "root path!") diff --git a/linspector/core/linspector.py b/linspector/core/linspector.py index f482936..c3c0d04 100644 --- a/linspector/core/linspector.py +++ b/linspector/core/linspector.py @@ -45,14 +45,25 @@ class Linspector: jobstores = { 'memory': MemoryJobStore() } - executors = { - 'default': ThreadPoolExecutor(int(configuration.get_option('linspector', - 'max_threads'))), - #'default': ProcessPoolExecutor(int(configuration.get_option('linspector', - # 'max_processes'))) - } + if configuration.get_option('linspector', 'max_threads') and not \ + configuration.get_option('linspector', 'scheduler_mode') == 'process': + executors = { + 'default': ThreadPoolExecutor(int(configuration.get_option('linspector', + 'max_threads'))) + } + else: + executors = { + 'default': ThreadPoolExecutor(1024) + } + if configuration.get_option('linspector', 'scheduler_mode'): + if configuration.get_option('linspector', 'scheduler_mode') == 'process': + executors = { + 'default': ProcessPoolExecutor(int(configuration.get_option('linspector', + 'max_processes'))) + } job_defaults = { - 'max_instances': 10000 + # every scheduler job (monitor) must only exist once. + 'max_instances': 1 } self.__scheduler['linspector'] = BackgroundScheduler(jobstores=jobstores, executors=executors,