[erlang-questions] Looking for info on hot code updates

Eranga Udesh <>
Thu Nov 1 13:38:37 CET 2007


Hot code update is not complicated as it sounds. 

Copy your new beam file to the place where you have the old module beam
file.

If you are updating a code of a non-running module, just run,
	l(<module_name>).
	c:l(<module_name>).
	code:purge(<module_name>).

If the code is running (eg. gen_server, gen_fsm, spawned process, etc.)
	If the state is not changing due to the module change and if the
process is OTP compliant, you can run
		code:soft_purge(<module_name>).
		code:load_file(<module_name>).

	If the state is changing and still the process is OTP compliant,
then you need to write the state conversion method under the code_change to
return the new state, extracted from the old state.

	If the process is not OTP compliant, just use l/1, c:l/1 or
code:purge/1, but in this case the process will actually terminate and if
it's started through a supervisor, will restart. Otherwise manual restart
will require.

Above is only for a single module update. If you want to do a full release
update, see Release Handling under OTP Design Principles in the Erlang
Manual.

BRgds,
- Eranga
	
 


-----Original Message-----
From: 
[mailto:] On Behalf Of David Mitchell
Sent: Thursday, November 01, 2007 4:26 PM
To: Erlang
Subject: [erlang-questions] Looking for info on hot code updates

Hello all,

Pure and simple - I'm looking for a pointer to info on doing hot code
updates (i.e. update code while a server is running) in Erlang.  I've
seen lots of talk about it, but nothing on:
- how to do it
- pros/cons/caveats/assumptions
- what happens when that code is currently being executed by a running
process

If there's some magic combination of keywords that'll get me this info
in Google, I can't work out what it is.  It's probably covered
extensively at www.erlang.org under the Documentation link, but I
can't find anything there either (probably just looking in the wrong
place).

Sorry if the request sounds pathetic, but I'm just confused why I
can't find this info when pretty much everything else on Erlang is
easy to find.  Maybe it's just a slow brain day for me today

Thanks in advance

Dave M.
_______________________________________________
erlang-questions mailing list

http://www.erlang.org/mailman/listinfo/erlang-questions





More information about the erlang-questions mailing list