Sha256: d165d3d55ab179c199519914192884777d669944273f65f62e810724498757fc

Contents?: true

Size: 1.09 KB

Versions: 9

Compression:

Stored size: 1.09 KB

Contents

-module(cap_runtime).
-include("capricorn.hrl").
-behaviour(gen_server).

-export([reboot/1, selfupdate/1, start_link/1]).
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).



reboot(Node) ->
  gen_server:call({cap_runtime, Node}, reboot, 60 * 1000).



selfupdate(Node) ->
  gen_server:call({cap_runtime, Node}, selfupdate, 15 * 60 * 1000).



start_link(NodeType) ->
  gen_server:start_link({local, cap_runtime}, ?MODULE, NodeType, []).



init(NodeType) ->
  {ok, NodeType}.



handle_call(selfupdate, From, NodeType) ->
  Install = os:cmd("bash -l -c \"gem install capricorn --pre\""),
  init:reboot(),
  gen_server:reply(From, list_to_binary(Install)),
  {noreply, NodeType};



handle_call(reboot, From, NodeType) ->
  ?LOG_DEBUG("rebooting", []),
  init:reboot(),
  gen_server:reply(From, ok),
  {noreply, NodeType}.



handle_cast(abcdefg, State) ->
  {noreply, State}.



handle_info({_, {data, Msg}}, State) ->
  ?LOG_DEBUG("reboot> ~s", [Msg]),
  {noreply, State}.



terminate(_Reason, _State) ->
  ok.



code_change(_OldVsn, State, _Extra) ->
  {ok, State}.


Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
capricorn-2.0.11 erlang/lib/capricorn/src/cap_runtime.erl
capricorn-2.0.10 erlang/lib/capricorn/src/cap_runtime.erl
capricorn-2.0.9 erlang/lib/capricorn/src/cap_runtime.erl
capricorn-2.0.8 erlang/lib/capricorn/src/cap_runtime.erl
capricorn-2.0.7 erlang/lib/capricorn/src/cap_runtime.erl
capricorn-2.0.6 erlang/lib/capricorn/src/cap_runtime.erl
capricorn-2.0.5 erlang/lib/capricorn/src/cap_runtime.erl
capricorn-2.0.4 erlang/lib/capricorn/src/cap_runtime.erl
capricorn-2.0.3 erlang/lib/capricorn/src/cap_runtime.erl