Permalink
Browse files

Implement code for the 'etorrentctl' shell script in etorrent_ctl.

We know support crude installation and commands like:

etorrentctl start
etorrentctl list
etorrentctl stop (currently with a nodedown artifact we kill later)
  • Loading branch information...
1 parent 9db1758 commit 6a8ee8865cfffb547332e1437144d7c1a75dfb13 @jlouis committed Jul 3, 2008
Showing with 21 additions and 11 deletions.
  1. +1 −1 Makefile
  2. +2 −3 bin/etorrentctl.in
  3. +4 −2 lib/etorrent-1.0/src/etorrent.erl
  4. +14 −5 lib/etorrent-1.0/src/etorrent_ctl.erl
View
@@ -34,5 +34,5 @@ install:
sed -e "s|%%%BEAMDIR%%%|$(RELEASE_PREFIX)/lib/etorrent-$(VER)/ebin|;" \
-e "s|%%%CONFIGFILE%%%|$(RELEASE_PREFIX)/lib/etorrent-$(VER)/priv/etorrent.config|;" \
-e "s|%%%ERL_FLAGS%%%|\"$(ERL_FLAGS)\"|" < ./bin/etorrentctl.in > $(BIN_PREFIX)/etorrentctl
+ chmod +x $(BIN_PREFIX)/etorrentctl
-
View
@@ -11,9 +11,8 @@ CONFIGFILE=%%%CONFIGFILE%%%
ERL_FLAGS=%%%ERL_FLAGS%%%
start () {
- # TODO: Add noshell and friends
erl ${ERL_FLAGS} -sname ${NODE}@${HOST} -pa ${BEAMDIR} \
- -config ${CONFIGFILE}
+ -config ${CONFIGFILE} -noshell -noinput -detached \
-s etorrent
}
@@ -26,7 +25,7 @@ debug () {
ctl () {
erl -noinput -sname etorrentctl@${HOST} \
-pa ${BEAMDIR} \
- -s etorrent_ctl -run start ${NODE}@${HOST} $@
+ -s etorrent_ctl start ${NODE}@${HOST} $@
}
usage () {
@@ -22,7 +22,8 @@ start(_Type, _Args) ->
etorrent_sup:start_link().
stop() ->
- application:stop(etorrent).
+ application:stop(etorrent),
+ halt().
stop(_State) ->
ok.
@@ -55,7 +56,8 @@ list() ->
help() ->
io:format("Available commands:~n", []),
- Commands = [{"list()", "List torrents in system"}],
+ Commands = [{"list", "List torrents in system"},
+ {"stop", "Stop the system"}],
lists:foreach(fun({Command, Desc}) ->
io:format("~-12.s - ~s~n", [Command, Desc])
@@ -25,7 +25,7 @@ start (Args) ->
case parse_arguments(Args) of
{Node, Commands} ->
Status = case rpc:call(Node, ?MODULE, process, [Commands]) of
- {badprc, Reason} ->
+ {badrpc, Reason} ->
io:format("RPC failed on node ~p: ~p~n",
[Node, Reason]),
?STATUS_BADRPC;
@@ -40,12 +40,21 @@ start (Args) ->
%%====================================================================
%% Internal functions
%%====================================================================
-process(["stop"]) ->
+process([stop]) ->
etorrent:stop(),
- ?STATUS_OK.
+ ?STATUS_OK;
+process([list]) ->
+ etorrent:list(),
+ ?STATUS_OK;
+process([help]) ->
+ etorrent:help(),
+ ?STATUS_USAGE;
+process([_]) ->
+ etorrent:help(),
+ ?STATUS_USAGE.
+
parse_arguments([Node | Cmds]) ->
- {list_to_atom(Node),
+ {Node,
Cmds}.
-

0 comments on commit 6a8ee88

Please sign in to comment.