tmuxp icon indicating copy to clipboard operation
tmuxp copied to clipboard

Launch daemonized scripts via before_script ?

Open Segaja opened this issue 3 years ago • 2 comments

I have a tmux session on my server which I previously managed by tmuxinator. Now I migrated this to tmuxp and ran into this problem:

╰─ ssh myserver.com -t tmuxp load -y mysession
[Loading] /home/segaja/.tmuxp/mysession.yaml
Traceback (most recent call last):
  File "/usr/bin/tmuxp", line 33, in <module>
    sys.exit(load_entry_point('tmuxp==1.9.4', 'console_scripts', 'tmuxp')())
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/lib/python3.10/site-packages/tmuxp/cli.py", line 1096, in command_load
    load_workspace(config[-1], **tmux_options)
  File "/usr/lib/python3.10/site-packages/tmuxp/cli.py", line 683, in load_workspace
    if builder.session_exists(session_name) and not append:
  File "/usr/lib/python3.10/site-packages/tmuxp/workspacebuilder.py", line 107, in session_exists
    self.session = self.server.find_where({'session_name': session_name})
  File "/usr/lib/python3.10/site-packages/libtmux/common.py", line 316, in find_where
    return self.where(attrs)[0]
  File "/usr/lib/python3.10/site-packages/libtmux/common.py", line 347, in where
    return list(filter(by, self.children))
  File "/usr/lib/python3.10/site-packages/libtmux/server.py", line 185, in sessions
    return self.list_sessions()
  File "/usr/lib/python3.10/site-packages/libtmux/server.py", line 180, in list_sessions
    return [Session(server=self, **s) for s in self._sessions]
  File "/usr/lib/python3.10/site-packages/libtmux/server.py", line 180, in <listcomp>
    return [Session(server=self, **s) for s in self._sessions]
  File "/usr/lib/python3.10/site-packages/libtmux/session.py", line 57, in __init__
    raise ValueError('Session requires a `session_id`')
ValueError: Session requires a `session_id`
Connection to myserver.com closed.

(Session name and server hostname abstracted.)

When I execute tmuxp load -y mysession directly on the server it works fine.

Segaja avatar Mar 02 '22 08:03 Segaja

  • https://github.com/amoffat/sh can daemonize / send to background apparently

    • https://github.com/amoffat/sh/blob/260e39cb9e360875337c9a86917370585dfeb4d6/sh.py#L1634-L1645
    • https://github.com/amoffat/sh/blob/1.14.2/sh.py#L2100-L2187

tony avatar Mar 28 '22 10:03 tony

Also one possibility is we can:

  • allow our plugin system have a plugin that can support these in config files
  • show an example of a python script that launches a apps daemonized

tony avatar Mar 28 '22 10:03 tony

I solved this by running the task that forks to background first and then invoke tmuxp.

@tony from my side this can be closed.

Segaja avatar Aug 31 '22 19:08 Segaja

@Segaja I will close this up - but I won't lock it, in case anyone wants to share an example of how they worked around it

If you have an example of what specifically you did to workaround you can bring it up here, too. (in case someone arrives here via search)

tony avatar Sep 01 '22 10:09 tony