Namdak Tonpa 9 years ago
parent
commit
2eb6fbac46
3 changed files with 35 additions and 0 deletions
  1. 12 0
      src/vox/vox_create.erl
  2. 18 0
      src/vox/vox_start.erl
  3. 5 0
      src/vox/vox_stop.erl

+ 12 - 0
src/vox/vox_create.erl

@@ -0,0 +1,12 @@
+-module(vox_create).
+-compile(export_all).
+
+command(Args) ->
+    lists:foldl(fun create/2,[],Args),
+    {ok,?MODULE}.
+
+create(App,Acc) ->
+    Name = filename:basename(App,".tgz"),
+    vox:info("Unpack Container: ~p~n",[Name]),
+    {ok,Bin} = file:read_file(App),
+    erl_tar:extract({binary,zlib:gunzip(Bin)},[{cwd,lists:concat(["apps/",Name])}]).

+ 18 - 0
src/vox/vox_start.erl

@@ -0,0 +1,18 @@
+-module(vox_start).
+-compile(export_all).
+
+command(Args) -> {ok,lists:map(fun start/1,Args)}.
+
+start(App) ->
+    vox:info("App: ~p~n",[App]),
+    {ok,Bin}  = file:read_file(lists:concat(["apps/",App,"/config.json"])),
+    {Json   } = jsone:decode(Bin),
+    {Process} = proplists:get_value(<<"process">>,Json),
+    Args      = proplists:get_value(<<"args">>,Process),
+    Concat    = string:join(lists:map(fun(X) -> binary_to_list(X) end,Args)," "),
+    {_,R,S}   = sh:run(Concat,<<"log">>,lists:concat(["apps/",App])),
+    vox:info("Oneliner: ~p~n",[Concat]),
+    {ret(R),S}.
+
+ret(0) -> ok;
+ret(_) -> error.

+ 5 - 0
src/vox/vox_stop.erl

@@ -0,0 +1,5 @@
+-module(vox_stop).
+-compile(export_all).
+
+command(Args) -> vox:info("~p Args: ~p~n",[?MODULE,Args]), {ok,?MODULE}.
+