Merge pull request #870 from mwhudson/reorg-syslog-ids
have the client unconditionally print whatever comes over one syslog id
This commit is contained in:
commit
25e107e522
|
@ -245,7 +245,10 @@ class SubiquityClient(TuiApplication):
|
|||
else:
|
||||
break
|
||||
print()
|
||||
self.event_syslog_id = status.event_syslog_id
|
||||
journald_listen(
|
||||
self.aio_loop,
|
||||
[status.echo_syslog_id],
|
||||
lambda e: print(e['MESSAGE']))
|
||||
if status.state == ApplicationState.STARTING:
|
||||
print("server is starting...", end='', flush=True)
|
||||
while status.state == ApplicationState.STARTING:
|
||||
|
@ -255,13 +258,8 @@ class SubiquityClient(TuiApplication):
|
|||
print()
|
||||
if status.state == ApplicationState.EARLY_COMMANDS:
|
||||
print("running early commands...")
|
||||
fd = journald_listen(
|
||||
self.aio_loop,
|
||||
[status.early_commands_syslog_id],
|
||||
lambda e: print(e['MESSAGE']))
|
||||
status.state = await self.client.meta.status.GET(cur=status.state)
|
||||
status = await self.client.meta.status.GET(cur=status.state)
|
||||
await asyncio.sleep(0.5)
|
||||
self.aio_loop.remove_reader(fd)
|
||||
return status
|
||||
|
||||
async def start(self):
|
||||
|
|
|
@ -36,7 +36,7 @@ class ApplicationState(enum.Enum):
|
|||
class ApplicationStatus:
|
||||
state: ApplicationState
|
||||
cloud_init_ok: bool
|
||||
early_commands_syslog_id: str
|
||||
echo_syslog_id: str
|
||||
log_syslog_id: str
|
||||
event_syslog_id: str
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ class CmdListController(NonInteractiveController):
|
|||
}
|
||||
cmds = ()
|
||||
cmd_check = True
|
||||
send_to_journal = False
|
||||
syslog_id = None
|
||||
|
||||
def __init__(self, app):
|
||||
super().__init__(app)
|
||||
|
@ -60,13 +60,12 @@ class CmdListController(NonInteractiveController):
|
|||
with context.child("command_{}".format(i), desc):
|
||||
if isinstance(cmd, str):
|
||||
cmd = ['sh', '-c', cmd]
|
||||
if self.send_to_journal:
|
||||
if self.syslog_id is not None:
|
||||
journal.send(
|
||||
" running " + desc,
|
||||
SYSLOG_IDENTIFIER=self.app.early_commands_syslog_id)
|
||||
" running " + desc, SYSLOG_IDENTIFIER=self.syslog_id)
|
||||
cmd = [
|
||||
'systemd-cat', '--level-prefix=false',
|
||||
'--identifier=' + self.app.early_commands_syslog_id,
|
||||
'--identifier=' + self.syslog_id,
|
||||
] + cmd
|
||||
await arun_command(
|
||||
cmd, env=env,
|
||||
|
@ -78,13 +77,20 @@ class CmdListController(NonInteractiveController):
|
|||
class EarlyController(CmdListController):
|
||||
|
||||
autoinstall_key = 'early-commands'
|
||||
send_to_journal = True
|
||||
|
||||
def __init__(self, app):
|
||||
super().__init__(app)
|
||||
self.syslog_id = app.echo_syslog_id
|
||||
|
||||
|
||||
class LateController(CmdListController):
|
||||
|
||||
autoinstall_key = 'late-commands'
|
||||
|
||||
def __init__(self, app):
|
||||
super().__init__(app)
|
||||
self.syslog_id = app.log_syslog_id
|
||||
|
||||
def env(self):
|
||||
env = super().env()
|
||||
env['TARGET_MOUNT_POINT'] = self.app.base_model.target
|
||||
|
@ -104,3 +110,11 @@ class ErrorController(CmdListController):
|
|||
|
||||
autoinstall_key = 'error-commands'
|
||||
cmd_check = False
|
||||
|
||||
@with_context()
|
||||
async def run(self, context):
|
||||
if self.app.interactive():
|
||||
self.syslog_id = self.app.log_syslog_id
|
||||
else:
|
||||
self.syslog_id = self.app.echo_syslog_id
|
||||
await super().run(context=context)
|
||||
|
|
|
@ -75,7 +75,7 @@ class MetaController:
|
|||
return ApplicationStatus(
|
||||
self.app.state,
|
||||
cloud_init_ok=self.app.cloud_init_ok,
|
||||
early_commands_syslog_id=self.app.early_commands_syslog_id,
|
||||
echo_syslog_id=self.app.echo_syslog_id,
|
||||
event_syslog_id=self.app.event_syslog_id,
|
||||
log_syslog_id=self.app.log_syslog_id)
|
||||
|
||||
|
@ -149,8 +149,7 @@ class SubiquityServer(Application):
|
|||
self.state_event = asyncio.Event()
|
||||
self.confirming_tty = ''
|
||||
|
||||
self.early_commands_syslog_id = 'subiquity_commands.{}'.format(
|
||||
os.getpid())
|
||||
self.echo_syslog_id = 'subiquity_echo.{}'.format(os.getpid())
|
||||
self.event_syslog_id = 'subiquity_event.{}'.format(os.getpid())
|
||||
self.log_syslog_id = 'subiquity_log.{}'.format(os.getpid())
|
||||
|
||||
|
|
Loading…
Reference in New Issue