Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
childpid = os.fork()
if childpid:
os.waitpid(childpid, 0)
else:
os.dup2(2, 1) # send log to stderr
failapp.log(interactive=False) # doesn't return
if state == 'start':
# we don't want services that failed to start to be 'up'
failapp.stop()
pgctl_print()
pgctl_print('There might be useful information further up in the log; you can view it by running:')
for service in failapp.services:
pgctl_print(' less +G {}'.format(bestrelpath(service.path.join('logs', 'current').strpath)))
raise PgctlUserMessage('Some services failed to %s: %s' % (state, commafy(failed)))
def reload(self):
"""Reloads the configuration for a service"""
pgctl_print('reload:', commafy(self.service_names))
raise PgctlUserMessage('reloading is not yet implemented.')
"""The pgctl supervision process has gone missing."""
class PgctlUserMessage(Exception):
"""
This is the class of user messages, as distinct from programmer errors.
For some cases, there's nothing better to do than send a message to the user.
When that happens, we don't need or want a stack trace.
"""
class CircularAliases(PgctlUserMessage):
"""The user has configured their pgctl aliases with a circular definition."""
class NoPlayground(PgctlUserMessage):
"""The pgctl system could find no playground to operate on."""
class NoSuchService(PgctlUserMessage):
"""The pgctl system could find the indicated playground service to operate on."""
class LockHeld(PgctlUserMessage):
"""The pgctl supervision lock is held. This generally indicates subprocesses escaping supervision."""
class NotReady(PgctlUserMessage):
"""The service is still performing its previous state change."""
def debug(self):
"""Allow a service to run in the foreground"""
try:
# start supervise in the foreground with the service up
service, = self.services
except ValueError:
raise PgctlUserMessage(
'Must debug exactly one service, not: ' + commafy(self.service_names),
)
if service.state['state'] != 'down':
self.stop()
self._run_playground_wide_hook('pre-start')
service.foreground() # never returns
"""raised only in cases that we believe to be impossible"""
class Unsupervised(Exception):
"""The pgctl supervision process has gone missing."""
class PgctlUserMessage(Exception):
"""
This is the class of user messages, as distinct from programmer errors.
For some cases, there's nothing better to do than send a message to the user.
When that happens, we don't need or want a stack trace.
"""
class CircularAliases(PgctlUserMessage):
"""The user has configured their pgctl aliases with a circular definition."""
class NoPlayground(PgctlUserMessage):
"""The pgctl system could find no playground to operate on."""
class NoSuchService(PgctlUserMessage):
"""The pgctl system could find the indicated playground service to operate on."""
class LockHeld(PgctlUserMessage):
"""The pgctl supervision lock is held. This generally indicates subprocesses escaping supervision."""
class NotReady(PgctlUserMessage):
"""The user has configured their pgctl aliases with a circular definition."""
class NoPlayground(PgctlUserMessage):
"""The pgctl system could find no playground to operate on."""
class NoSuchService(PgctlUserMessage):
"""The pgctl system could find the indicated playground service to operate on."""
class LockHeld(PgctlUserMessage):
"""The pgctl supervision lock is held. This generally indicates subprocesses escaping supervision."""
class NotReady(PgctlUserMessage):
"""The service is still performing its previous state change."""