common setup utility and call for convention
Ulf Wiger
ulf.wiger@REDACTED
Mon Jan 3 10:08:11 CET 2011
Since some people were asking on twitter, I put up some code
that you could say is an evolution of my old 'builder' project
(found in Jungerl, and used e.g. by CEAN), and also of the concepts
used in AXD 301 for creating a modular and extensible install script.
http://github.com/esl/setup
For quick perusal:
https://github.com/esl/setup/blob/master/README.md
https://github.com/esl/setup/blob/master/doc/README.md
The app contains only two modules - one (setup_gen) for building
.rel file and OTP boot script from a simple config, and one (setup)
for implementing a pluggable installation utility, for initializing databases,
creating tables, etc.
I think they're pretty useful, even at this stage (setup.erl is ca 200 LOC,
setup_gen.erl is ca 400 LOC).
I will freely admit that setup_gen is a quick-and-dirty reaction to not having
the time to figure out how to make reltool do something really simple (well,
rebar *almost* does that for you, but for me, it was easier to write setup_gen,
since I've done it so many times before).
The setup module proposes a convention for specifying install hooks, and
I think it would be very helpful if we could start using a common method.
In short, if you don't want to follow the above links, you'd add an environment
variable to your app:
{'$setup_hooks', [ {PhaseNumber, [{M,F,A}]} ]}
and the 'setup' utility will collect all hooks, sort them and call them sequentially.
PhaseNumber should be an integer, and my initial suggestion is to use
100 for creating your database, 200 for modifying its schema and 300 for filling
it with data. There may be other ubiquitous phases, but it's probably a good idea
to keep that list short.
I'd really appreciate comments. Perhaps this has broader utility than my
esoteric experiments extending mnesia? :)
BR,
Ulf W
Ulf Wiger, CTO, Erlang Solutions, Ltd.
http://erlang-solutions.com
More information about the erlang-questions
mailing list