-
Notifications
You must be signed in to change notification settings - Fork 22
Deployment
I currently run the bot in a Ubuntu 9.10 virtual machine, connected to freenode (the nickname is erlbot--).
I'm running it with the help of [[runit|http://smarden.org/runit/] and a small escript. In the directory of the bot (a clone of this git repo), I've created a service
subdirectory, and there I have the runit run
script:
#!/bin/sh
exec 2>&1
export HOME=/home/damjan
cd ..
export ERL_LIBS=$PWD/deps
exec chpst -udamjan ./run.e
the service
subdir is linked from runit's /etc/service/
directory. ERL_LIBS is exported there for the couchbeam
package (and its dependencies) that's installed there.
The ./run.e
escript start the application and registers the bot so that it's available in a remote shell:
%% -*- erlang -*-
%%! -boot start_sasl -pa ebin -sname ircbot@localhost
main([]) ->
main(["settings.cfg"]);
main([Filename]) ->
io:setopts([{encoding, unicode}]),
{ok, Settings} = file:consult(Filename),
IrcBot = ircbot_fsm:new_link(Settings),
register(ircbot, IrcBot:pid()),
IrcBot:connect(),
loop_forever().
loop_forever() ->
receive _ -> ok end,
loop_forever().
By default it's using the settings.cfg
file in the source dir. An example of is included with the source.
To connect to the running bot, you can use the erlang remote shell:
$ erl -remsh ircbot@localhost -sname rem
1> IrcBot = ircbot_api:new(whereis(ircbot)).
Look at the ircbot_api.erl file for the available "methods".