Chia-Network / chia-blockchain

Chia blockchain python implementation (full node, farmer, harvester, timelord, and wallet)
Apache License 2.0
10.82k stars 2.03k forks source link

[Bug] "chia start" doesn't exit if invoked via ssh #16396

Open cross opened 1 year ago

cross commented 1 year ago

What happened?

From one host, I deploy commands to a farm of chia harvesters. "chia stop" and other commands exit as I'd expect, but "chia start harvester" does not. It completes, reporting success, then just hangs. Eventually I will have to cancel/timeout the session.

me@localhost ~> ssh chiauser@hostname chia start harvester
chiauser@hostname's password: 
Daemon not started yet
Starting daemon
chia_harvester: started

At this point, the ssh session just remains open. The daemon and harvester are running, but the shell doesn't exit. I presume this is something to do with not properly daemon-izing the processes, holding a controlling terminal.

Version

2.0.1

What platform are you using?

Linux

What ui mode are you using?

CLI

Relevant log output

No response

cross commented 1 year ago

If I log into another terminal and chia stop all -d, the ssh will exit. chia stop all beforehand left that ssh remaining open. That confirms it's the daemon, not the harvester, that is the thing holding the tty.

wiryonolau commented 1 year ago

you can run in tmux, or pass it to backgorund worker

chia start harvester &

Or use systemd

cross commented 1 year ago

True, but when invoking via ssh those are harder. I think it's just an issue of it needing to release its controlling terminal before the parent exits. It's an edge condition, but shouldn't be too hard to fix.

cai1111 commented 1 year ago

nohup chia start harvester &

cross commented 1 year ago

That doesn't work either, at least not via ssh. (adding \& to ssh has no effect)

cross@hostname ~> ssh user@chiahost nohup chia start harvester
user@chiahost's password: 
Daemon not started yet
Starting daemon
chia_harvester: started

and then it hangs.

cai1111 commented 1 year ago

ssh user@chiahost "sh -c 'nohup chia start harvester > /dev/null 2>&1 &'"

wjblanke commented 1 year ago

We are leaving this open for a fix, but tbh it is pretty low priority at the moment