zellij-org / zellij

A terminal workspace with batteries included
https://zellij.dev
MIT License
22.03k stars 673 forks source link

Keep processes open within zellij session after disconnecting from SSH ? #3531

Open romaric-siri opened 4 months ago

romaric-siri commented 4 months ago

Hello,

I wanted to know if thats a zellij bug or thats something I don't understand, here what I did :

But : When I log back, the process has stopped automatically and zellij asks me to re run it

This is before I detach the session (the process I want to keep open)

azeazezae

This is after I reconnect and re-attach the zellij session, the process has stopped ...

after

Is it normal ? Is there a way to keep that process open within zellij even after I disconnect from SSH, and to have it back when I re-attach the session?

Thanks for your help.

imsnif commented 4 months ago

It's very likely that something on the server is killing the detached Zellij process (eg. systemd is notorious for doing this to processes that are not owned by any connected user). I'd try looking in that direction.

jwilger commented 3 months ago

@romaric-siri I'm guessing your server is running systemd? By default, systemd kills all user processes on logout. This is a departure from the old initrc setups. It's nothing to do with zellij per se.

wllenyj commented 1 month ago

Why the tmux can hold on to its process on the same Ubuntu?

I often use tmux as nohup to run some job to background. But zellij can't work to this case.

romaric-siri commented 1 month ago

That's what i was wondering, I have no problem when running Screen for similar use case ...

chubi-x commented 1 month ago

I'm wondering if there's any news with this as I have the same problem and it happens even when running locally. Whenever i resurrect a session my progress isn't actually saved since the process is not persisted as zellij just runs it again from the top.

adaschma commented 2 weeks ago

@chubi-x @wllenyj @romaric-siri I have written some documentation to help: https://github.com/adaschma/zellij-org.github.io/blob/systemd-integration/docs/src/integration.md#keep-session-running-after-logout-on-systemd

Please tell me, if it is clear and works for you or any suggested changes. I will then send a pull request to make it part of the official documentation.

adaschma commented 1 week ago

It has now been a week and I haven't heard from anybody. @chubi-x @wllenyj @romaric-siri did you have a chance to read it? Or do you still plan on doing so?

chubi-x commented 1 week ago

Sorry for the late reply @adaschma. The suggested command didn't work for me on linux ubuntu 24.04. I had to use systemd-run instead of systemd-bin. Also i'm running zellij as the default shell for alacritty so I don't know how the suggested command will integrate with that since zellij is started by alacritty.

adaschma commented 1 week ago

Thanks @chubi-x for catching that. Don't know how I missed that. Fixed it. In alacritty.toml you can add something like:

[shell] program = "systemd-run" args = ["--scope", "--user", "zellij"]