<div dir="ltr"><div>Hi Erlangers,</div><div><br></div><div>I am trying to understand how hot patch upgrade is done in Erlang, I got this piece of code from stackoverflow, but I ran into 2 issues when I played around with it.</div><div><br></div><div>Issue 1)  In the piece of code, I suppose to send a message 'upgrade' to the running process, then it will finish the upgrade. It is working fine with "?MODULE:loop();", but if I remove the prefix ?MODULE in the code, then the upgrade will be failed, I mean when I send message 'run' after upgrade neither the new message nor the old message are printed.</div><div><br></div><div>Issue 2) I was told if I recompile and reload the updated file from shell, then it will be done as well.</div><div>So, I did this from shell, update the source file -> compile the file -> reload it ->send msg 'run' to the same process -> 'new version' is not printed out.   What could be the mistake? </div><div>  <br></div><div><br></div><div><br></div><div>-module(test_hot_swap).</div><div><br></div><div>-export([loop/0]).</div><div><br></div><div>loop() -></div><div>    receive</div><div>        upgrade -></div><div>            code:purge(?MODULE),</div><div>            compile:file(?MODULE),</div><div>            code:load_file(?MODULE),       </div><div>            ?MODULE:loop();                                    %%without ?MODULE, it has problem.</div><div>        run -></div><div>            io:format("This is a new version ~n"),       %% before upgrade, the text is  'old version'.</div><div>            loop();</div><div>        _ -></div><div>            loop()</div><div>    end.</div><div><br></div><div>Thank you.</div><div><br></div><div>Br,</div><div>Alex</div></div>