tsl0922 / ttyd

Share your terminal over the web
https://tsl0922.github.io/ttyd
MIT License
8.23k stars 899 forks source link

process terminates on webpage exit #53

Closed LoganDark closed 7 years ago

LoganDark commented 7 years ago

How do I stop this? (Even if it is not a bug)

tsl0922 commented 7 years ago

This is expected, as well as ssh does. You may use tools like nohup to keep process running in background.

LoganDark commented 7 years ago

nohup makes my docker process stay alive after ttyd ends. and then I have to kill it manually, how do I fix this?

LoganDark commented 7 years ago

ttyd just kills the process when the browser closes, I want it to stay open after the webpage closes but I still want it to close when I kill ttyd.

tsl0922 commented 7 years ago

Not support, this seems not the use scene of ttyd.

LoganDark commented 7 years ago

I mean like where I can visit the webpage at any time and have access to the running process

tsl0922 commented 7 years ago

I want it to stay open after the webpage closes but I still want it to close when I kill ttyd

This is not possible, ttyd always send quit signal to process when client disconnected. if you want to share one terminal with multiple users, you can use a terminal multiplexer like tmux, for example: ttyd tmux new -A -s ttyd vim.

LoganDark commented 7 years ago

nope, not what I want. what I want is a session I can always connect to in the browser. i'm not going to be sharing it with others.

sorry if i'm bothering you, but you don't seem to understand what I want

tsl0922 commented 7 years ago

I Understood, but it is not possible for ttyd right now, so I gave you some workarounds.

What you want is something like tmux session managed by ttyd which maps connect to attach, disconnect to detach?

LoganDark commented 7 years ago

can't you just add like a --nokill option, something likeDoesn't shut down process on client disconnect?

i'd add that option myself but i have no idea how :/

tsl0922 commented 7 years ago

No. ttyd doesn't store session, if it Doesn't shut down process on client disconnect, that process will be stale, we can't identify which client it belongs to.

LoganDark commented 7 years ago

I give up...

wuestkamp commented 4 years ago

Would it be possible to put an (Nginx) proxy in front which always keeps the connection alive and accepts coming and going connections and transfers these to the same session? For the ttyd it would just seem that there is one long-running connection. Anyone got experience with this?

devopswise commented 1 year ago

I am looking for same functionality. I need to keep the session running and access whenever I need to, using browser. I appreciate if there are any updates or ideas? Many thanks

dmartin commented 1 year ago

I agree with the maintainer, this feature doesn't really make sense to handle in ttyd. It can be done with tools designed for running persistent sessions:

# start some persistent background terminal session (could also use tmux, Docker, etc)
screen -dmS htop-session htop

# attach to it when users connect to ttyd
ttyd bash -c 'screen -r htop-session'
devopswise commented 1 year ago

I also agree with the maintainer and many thanks for the solution @dmartin In case somebody needs it, here I am leaving a link to my image

https://github.com/devopswise/wspacer-basic-workspace