mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
first commit
This commit is contained in:
@@ -19,6 +19,8 @@ Global/Universal
|
||||
- **PATRONI\_LOG\_FILE\_NUM**: The number of application logs to retain.
|
||||
- **PATRONI\_LOG\_FILE\_SIZE**: Size of patroni.log file (in bytes) that triggers a log rolling.
|
||||
- **PATRONI\_LOG\_LOGGERS**: Redefine logging level per python module. Example ``PATRONI_LOG_LOGGERS="{patroni.postmaster: WARNING, urllib3: DEBUG}"``
|
||||
- **PATRONI\_DEBUG\_MODE**: When set to a non-empty value, makes Patroni run in the special debug mode that enables stepping with a debugger through some execution paths within Patroni `
|
||||
Example ``PATRONI_DEBUG_MODE="on"``
|
||||
|
||||
Bootstrap configuration
|
||||
-----------------------
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
#!/usr/bin/env python
|
||||
from patroni import main
|
||||
|
||||
import os
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
if os.getenv("PATRONI_DEBUG_MODE"):
|
||||
# XXX Visual Code specific https://github.com/microsoft/ptvsd/issues/1443
|
||||
# create processes by spawning new Python interpreters instead of forking the current one
|
||||
import multiprocessing
|
||||
multiprocessing.set_start_method('spawn', True)
|
||||
|
||||
main()
|
||||
|
||||
+4
-2
@@ -32,6 +32,7 @@ class Patroni(object):
|
||||
self.postgresql = Postgresql(self.config['postgresql'])
|
||||
self.api = RestApiServer(self, self.config['restapi'])
|
||||
self.ha = Ha(self)
|
||||
self.is_in_debug_mode = bool(os.getenv("PATRONI_DEBUG_MODE"))
|
||||
|
||||
self.tags = self.get_tags()
|
||||
self.next_run = time.time()
|
||||
@@ -102,8 +103,9 @@ class Patroni(object):
|
||||
self.next_run = current_time
|
||||
# Release the GIL so we don't starve anyone waiting on async_executor lock
|
||||
time.sleep(0.001)
|
||||
# Warn user that Patroni is not keeping up
|
||||
logger.warning("Loop time exceeded, rescheduling immediately.")
|
||||
# Warn user that Patroni is not keeping up or runs in debug
|
||||
msg = "Patroni runs in the debug mode: keys' TTL is infinite, loop wait disabled" if self.is_in_debug_mode else "Loop time exceeded, rescheduling immediately."
|
||||
logger.warning(msg)
|
||||
elif self.ha.watch(nap_time):
|
||||
self.next_run = time.time()
|
||||
|
||||
|
||||
@@ -333,6 +333,11 @@ class Config(object):
|
||||
elif name not in config or name in ['watchdog']:
|
||||
config[name] = deepcopy(value) if value else {}
|
||||
|
||||
if os.getenv("PATRONI_DEBUG_MODE"):
|
||||
config['ttl'] = 24 * 60 * 60 # practical infinity for a debugging session
|
||||
config['loop_wait'] = -1
|
||||
|
||||
|
||||
# restapi server expects to get restapi.auth = 'username:password'
|
||||
if 'authentication' in config['restapi']:
|
||||
config['restapi']['auth'] = '{username}:{password}'.format(**config['restapi']['authentication'])
|
||||
|
||||
Reference in New Issue
Block a user