erlware / relx

Sane, simple release creation for Erlang
http://erlware.github.io/relx
Apache License 2.0
696 stars 233 forks source link

First "daemon" startup hangs if no cookie is specified #905

Open weiss opened 2 years ago

weiss commented 2 years ago

If no ~/.erlang.cookie file exists and -setcookie isn't specified, using the extended start script's daemon command will hang forever waiting for RPC to work, as erl_rpc is called without a cookie being handed over to the -c flag. (This happens with OTP 23+, but not when using nodetool.)

Not quite sure of the best way to address this. Maybe just assume that using the extended start script implies RPC, so rather than warning about a missing cookie, just create a cookie file early on (and abort if this fails)? I mean the VM will attempt to create the file anyway, unless -(s)name is omitted.

(Kinda related to #803, where I'd like to avoid using erl_rpc's -c flag if a cookie file exists.)

tsloughter commented 2 years ago

To make sure I understand, you are relying on the fact the VM creates a cookie on boot if none is given and no ~/.erlang.cookie file exists? But since that file isn't created until boot it isn't available to be put on a variable COOKIE and passed to erl_rpc?

I think the fix is to check if COOKIE is empty before line 332 and to not pass -c if it is -- erl_call will read ~/.erlang.cookie in that case.

weiss commented 2 years ago

To make sure I understand, you are relying on the fact the VM creates a cookie on boot if none is given and no ~/.erlang.cookie file exists? But since that file isn't created until boot it isn't available to be put on a variable COOKIE and passed to erl_rpc?

Yes to both.

I think the fix is to check if COOKIE is empty before line 332 and to not pass -c if it is -- erl_call will read ~/.erlang.cookie in that case.

Ah yes, that might do the trick.