Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep a remote server awake after closing SSH connection? #360

Open
fohrloop opened this issue Jun 7, 2024 · 2 comments
Open

Keep a remote server awake after closing SSH connection? #360

fohrloop opened this issue Jun 7, 2024 · 2 comments

Comments

@fohrloop
Copy link
Owner

fohrloop commented Jun 7, 2024

Sometimes it might be useful to be able to ssh into a server, start a python process and disconnect from the server knowing that the process will continue running.

Todo:

  • what does this require?
  • Why a server without desktop environment stops executing a task?
  • is the solution such that could be included in wakepy?

Notes:

@fohrloop
Copy link
Owner Author

fohrloop commented Jun 8, 2024

I did a quick look on this topic. I'm not an expert on this but it seems that the reason why a script typically stops when someone exits SSH is a SIGHUP signal which gets send to all processes when terminal window with SSH connection is closed. The typical solutions involve using nohup, screen or tmux. This is not about keeping CPU awake, but about keeping a process from not getting stopped by a HUP signal. Therefore, I kind of think this might be out of scope of wakepy. If nohup yourscript.py & just works, why would wakepy need to implement a solution? If there was a solution, should that be some separate mode, like ignore.hup ?

In order to really consider adding a ignore.hup mode, should:

  • List at least one real use case, and explain why wakepy would be needed instead of nohup, screen or tmux?
  • Is this technically possible? Would it be as simple as:
import logging
import signal

logger = logging.getLogger(__name__)

def handler(signum, frame):
  logger.warning(f"Received {signum} signal. Doing nothing.")

signal.signal(signal.SIGHUP, handler)

@fohrloop fohrloop changed the title Keep a remote server awake? Keep a remote server awake after closing SSH connection? Jun 8, 2024
@fohrloop
Copy link
Owner Author

fohrloop commented Jun 8, 2024

Related: #203

Also could be possible to make wakepy ignore SIGHUP, by default but that's probably a bit too intrusive. Another possibility would be to add some nohup=False parameter to keep.running() and keep.presenting().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant