diff --git a/Makefile b/Makefile index 5b63e43..e5999c1 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,7 @@ CACHE_DIR ?= $(HOME)/.cache/rebar3 # HOSTNAME ?= $(shell hostname) COOKIE ?= MyCookie VERSION ?= 0.1.0 +DEPLOY_DEST ?= /media/laymer/GRISP # MAKE = make # # .PHONY: grispbuild rel deps plots dcos logs fpm no-cfg-build tarball-build \ @@ -27,7 +28,7 @@ VERSION ?= 0.1.0 # .PHONY: grispbuild rel deps test plots dcos logs fpm no-cfg-build tarball-build build -.PHONY: compile testshell shell 2shell 3shell deploy 10deploy 11deploy rel stage \ +.PHONY: compile testshell shell 2shell 3shell deploy 10deploy 11deploy rel stage doubledeploy ndeploy \ # cleaning targets : wipe clean buildclean grispclean cacheclean elixirclean checkoutsclean ⁠\ # currently not working targets : @@ -115,16 +116,44 @@ rel: prod-app-src stage: prod-app-src $(REBAR) release -d -deploy: prod-app-src - $(REBAR) grisp deploy -n $(GRISPAPP) -v $(VERSION) +# deploy: prod-app-src +# $(REBAR) grisp deploy -n $(GRISPAPP) -v $(VERSION) +# +# 1deploy: prod-app-src +# cp $(DEPLOYMENTS_DIR)/1/grisp.ini.mustache $(GRISPFILES_DIR)/grisp.ini.mustache +# $(REBAR) grisp deploy -n $(GRISPAPP) -v $(VERSION) +# +# 2deploy: prod-app-src +# cp $(DEPLOYMENTS_DIR)/2/grisp.ini.mustache $(GRISPFILES_DIR)/grisp.ini.mustache +# $(REBAR) grisp deploy -n $(GRISPAPP) -v $(VERSION) -1deploy: prod-app-src - cp $(DEPLOYMENTS_DIR)/1/grisp.ini.mustache $(GRISPFILES_DIR)/grisp.ini.mustache - $(REBAR) grisp deploy -n $(GRISPAPP) -v $(VERSION) -2deploy: prod-app-src +doubledeploy: deploy 1deploy + echo "deployed" + +ndeploy: + cp $(DEPLOYMENTS_DIR)/$(n)/grisp.ini.mustache $(GRISPFILES_DIR)/grisp.ini.mustache + rm -rdf $(DEPLOY_DEST)$(d)/* + $(REBAR) grisp deploy -n $(GRISPAPP) -v $(VERSION) --destination $(DEPLOY_DEST)$(d) --force true + umount $(DEPLOY_DEST)$(d) + +deploy: + # cp $(DEPLOYMENTS_DIR)/$(n)/grisp.ini.mustache $(GRISPFILES_DIR)/grisp.ini.mustache + rm -rdf $(DEPLOY_DEST)/* + $(REBAR) grisp deploy -n $(GRISPAPP) -v $(VERSION) --destination $(DEPLOY_DEST) --force true + umount $(DEPLOY_DEST) + +1deploy: cp $(DEPLOYMENTS_DIR)/2/grisp.ini.mustache $(GRISPFILES_DIR)/grisp.ini.mustache - $(REBAR) grisp deploy -n $(GRISPAPP) -v $(VERSION) + rm -rdf $(DEPLOY_DEST)1/* + $(REBAR) grisp deploy -n $(GRISPAPP) -v $(VERSION) --destination $(DEPLOY_DEST)1 --force true + umount $(DEPLOY_DEST)1 + +3deploy: + cp $(DEPLOYMENTS_DIR)/3/grisp.ini.mustache $(GRISPFILES_DIR)/grisp.ini.mustache + rm -rdf $(DEPLOY_DEST)/* + $(REBAR) grisp deploy -n $(GRISPAPP) -v $(VERSION) --destination $(DEPLOY_DEST) --force true + umount $(DEPLOY_DEST) 10deploy: prod-app-src cp $(DEPLOYMENTS_DIR)/10/grisp.ini.mustache $(GRISPFILES_DIR)/grisp.ini.mustache diff --git a/config/sys.config b/config/sys.config index 3c4c888..bce0049 100644 --- a/config/sys.config +++ b/config/sys.config @@ -16,7 +16,7 @@ {generic_tasks_sets_names, [tasks]}, {data_crdts_names, [{temp, dont_flush_crdt}]}, {generic_tasks_restart_interval, 30000}, - {gc_interval, 60000}, + {gc_interval, 40000}, {emulate_als, false}, {als_stream_interval, 180000}, {als_propagation_treshold, 10}, @@ -27,7 +27,7 @@ % beforehand using erl_inetrc config file {remote_hosts, % #{webservers => ['nodews@Laymer'], - #{webservers => ['ws@GrispAdhoc'], + #{webservers => ['ws@GrispAdhoc','ws@Laymer','ws@laymer-3'], aws_servers => [], main_aws_server => []} }, diff --git a/grisp/grisp_base/files/erl_inetrc b/grisp/grisp_base/files/erl_inetrc index eb0fb0a..5bb3440 100644 --- a/grisp/grisp_base/files/erl_inetrc +++ b/grisp/grisp_base/files/erl_inetrc @@ -5,6 +5,8 @@ % {host, {169,254,91,23}, ["Laymer-3"]}. % {host, {192,168,1,39}, ["Laymer"]}. {host, {169,254,187,88}, ["GrispAdhoc"]}. +{host, {169,254,187,89}, ["Laymer"]}. +{host, {169,254,187,90}, ["laymer-3"]}. %--- GRiSP boards -------------------------------------------------------------- {host, {169,254,16,1}, ["my_grisp_board_1"]}. {host, {169,254,16,2}, ["my_grisp_board_2"]}. diff --git a/priv/deployment_args/1/grisp.ini.mustache b/priv/deployment_args/1/grisp.ini.mustache index 920267d..c78d69c 100644 --- a/priv/deployment_args/1/grisp.ini.mustache +++ b/priv/deployment_args/1/grisp.ini.mustache @@ -2,9 +2,9 @@ image_path = /media/mmcsd-0-0/{{release_name}}/erts-{{erts_vsn}}/bin/beam.bin [erlang] -args = erl.rtems -- +MHas aobf +MMmcs 5 +MHlmbcs 5240 -mode embedded -home . -pa . -root {{release_name}} -config {{release_name}}/releases/{{release_version}}/sys.config -boot {{release_name}}/releases/{{release_version}}/{{release_name}} -internal_epmd epmd_sup -kernel inetrc "./erl_inetrc" -name {{release_name}}@my_grisp_board_1 -setcookie MyCookie +args = erl.rtems -- +MHas aobf +MMmcs 5 +MHlmbcs 512 -mode embedded -home . -pa . -root {{release_name}} -config {{release_name}}/releases/{{release_version}}/sys.config -boot {{release_name}}/releases/{{release_version}}/{{release_name}} -internal_epmd epmd_sup -kernel inetrc "./erl_inetrc" -sname {{release_name}} -setcookie MyCookie [network] -ip_self=dhcp +ip_self=169.254.16.1 wlan=enable hostname=my_grisp_board_1 diff --git a/priv/deployment_args/2/grisp.ini.mustache b/priv/deployment_args/2/grisp.ini.mustache index 9129c75..df224e9 100644 --- a/priv/deployment_args/2/grisp.ini.mustache +++ b/priv/deployment_args/2/grisp.ini.mustache @@ -2,10 +2,9 @@ image_path = /media/mmcsd-0-0/{{release_name}}/erts-{{erts_vsn}}/bin/beam.bin [erlang] -args = erl.rtems -- +MHas aobf +MMmcs 5 +MHlmbcs 5240 -mode embedded -home . -pa . -root {{release_name}} -config {{release_name}}/releases/{{release_version}}/sys.config -boot {{release_name}}/releases/{{release_version}}/{{release_name}} -internal_epmd epmd_sup -kernel inetrc "./erl_inetrc" -name {{release_name}}@my_grisp_board_2 -setcookie MyCookie +args = erl.rtems -- +MHas aobf +MMmcs 5 +MHlmbcs 512 -mode embedded -home . -pa . -root {{release_name}} -config {{release_name}}/releases/{{release_version}}/sys.config -boot {{release_name}}/releases/{{release_version}}/{{release_name}} -internal_epmd epmd_sup -kernel inetrc "./erl_inetrc" -sname {{release_name}} -setcookie MyCookie [network] -ip_self=dhcp +ip_self=169.254.16.2 wlan=enable hostname=my_grisp_board_2 -wpa=wpa_supplicant.conf diff --git a/priv/deployment_args/3/grisp.ini.mustache b/priv/deployment_args/3/grisp.ini.mustache new file mode 100644 index 0000000..4c1f149 --- /dev/null +++ b/priv/deployment_args/3/grisp.ini.mustache @@ -0,0 +1,10 @@ +[boot] +image_path = /media/mmcsd-0-0/{{release_name}}/erts-{{erts_vsn}}/bin/beam.bin + +[erlang] +args = erl.rtems -- +MHas aobf +MMmcs 5 +MHlmbcs 512 -mode embedded -home . -pa . -root {{release_name}} -config {{release_name}}/releases/{{release_version}}/sys.config -boot {{release_name}}/releases/{{release_version}}/{{release_name}} -internal_epmd epmd_sup -kernel inetrc "./erl_inetrc" -sname {{release_name}} -setcookie MyCookie + +[network] +ip_self=169.254.16.3 +wlan=enable +hostname=my_grisp_board_3 diff --git a/rebar.config b/rebar.config index 35b474c..9a9d005 100644 --- a/rebar.config +++ b/rebar.config @@ -58,9 +58,9 @@ % {directory,"/home/laymer/EdgeComputing/NewGRiSP/grisp-software/rtems-install/rtems/5"}]} ]}, {deploy, [ - {pre_script, "rm -rf /media/laymer/GRISP/*"}, % Igor - {destination, "/media/laymer/GRISP"}, % Igor - {post_script, "umount /media/laymer/GRISP"} % Igor + % {pre_script, "rm -rf /media/laymer/GRISP/*"}, % Igor + % {destination, "/media/laymer/GRISP"} % Igor + % {post_script, "umount /media/laymer/GRISP"} % Igor % #{relname => "node", relvsn => "0.1.0"} % {relname, "node"}, % {relvsn, "0.1.0"}, @@ -117,10 +117,11 @@ {recon, {git, "https://github.com/ferd/recon.git", {branch, "master"}}}, {lasp, {git, "https://github.com/lasp-lang/lasp.git", {branch, "master"}}}, partisan, - {lager, {git, "https://github.com/erlang-lager/lager.git", {branch, "master"}}}, - {flow, {elixir, "flow", "0.14.2"}}, - {gen_stage, {elixir, "gen_stage", "0.14.0"}}, - {numerix, {elixir, "numerix", "0.5.1"}} + {lager, {git, "https://github.com/erlang-lager/lager.git", {branch, "master"}}} + % {lager, {git, "https://github.com/erlang-lager/lager.git", {branch, "master"}}}, + % {flow, {elixir, "flow", "0.14.2"}}, + % {gen_stage, {elixir, "gen_stage", "0.14.0"}}, + % {numerix, {elixir, "numerix", "0.5.1"}} ]}, {shell, [{apps, [node]}, {config, "config/test.config"}]}, @@ -136,10 +137,10 @@ {include_erts, false}, {sys_config, "config/test.config"}, {extended_start_script, true} - ]}, - {provider_hooks, [ - {pre, [{compile, {ex, compile}}]} ]} + % {provider_hooks, [ + % {pre, [{compile, {ex, compile}}]} + % ]} ]} ]}. diff --git a/src/node.app.src b/src/node.app.src index 0bc6e7b..fb60420 100644 --- a/src/node.app.src +++ b/src/node.app.src @@ -8,6 +8,8 @@ stdlib, sasl, grisp + % sasl + % grisp % os_mon % grisp, % os_mon, diff --git a/src/node_generic_tasks_functions.erl b/src/node_generic_tasks_functions.erl index d23f9c7..00a73eb 100644 --- a/src/node_generic_tasks_functions.erl +++ b/src/node_generic_tasks_functions.erl @@ -291,17 +291,19 @@ all_sensor_data(Index, Nav, Als) -> timer:sleep(5000), all_sensor_data(Index+1,Nav,Als). -cave_data(Index) -> +cellar_data(Index) -> {pmod_nav, Nav, _} = node_util:get_nav(), {pmod_als, Als, _} = node_util:get_als(), - cave_data(Index,Nav,Als). + cellar_data(Index,Nav,Als). -cave_data(Index, Nav, Als) -> +cellar_data(Index, Nav, Als) -> [RawPress, RawTemp] = gen_server:call(Nav, {read, alt, [press_out, temp_out], #{}}), Press = verify(pressure, RawPress, Nav), Temp = verify(temp, RawTemp, Nav), - Mag = gen_server:call(Nav, {read, mag, [out_x_m, out_y_m, out_z_m], #{}}), - Gyro = gen_server:call(Nav, {read, acc, [out_x_g, out_y_g, out_z_g], #{}}), + % Mag = gen_server:call(Nav, {read, mag, [out_x_m, out_y_m, out_z_m], #{}}), + % Gyro = gen_server:call(Nav, {read, acc, [out_x_g, out_y_g, out_z_g], #{}}), + Mag = node_util:gebirgsjager(10), + Gyro = node_util:gebirgsjager(30), Raw = gen_server:call(Als, raw), {_,{H,Mi,_}} = calendar:local_time(), %% http://erlang.org/doc/programming_examples/bit_syntax.html @@ -312,7 +314,7 @@ cave_data(Index, Nav, Als) -> %% floats. {ok, {_, _, _, _}} = lasp:update(node_util:atom_to_lasp_identifier(node(),state_gset), {add, [Index, H*60 + Mi,Raw,Press,Temp,Mag,Gyro]}, self()), timer:sleep(5000), - cave_data(Index+1,Nav,Als). + cellar_data(Index+1,Nav,Als). verify(Type, Val, Nav) -> case Type of diff --git a/src/node_util.erl b/src/node_util.erl index d14c3ab..67cbb62 100644 --- a/src/node_util.erl +++ b/src/node_util.erl @@ -225,7 +225,8 @@ maybe_get_time(local) -> calendar:local_time(). form_squadron() -> - Remotes = [node()] ++ nodes(), + remotes2(), + Remotes = nodes(), _Reached = lists:foreach(fun (Elem) -> ?PAUSE3, @@ -239,16 +240,16 @@ form_squadron() -> end, Remotes), ok. -cavetask() -> - node_generic_tasks_server:add_task({cavetask, all, fun () -> node_generic_tasks_functions:cave_data(0) end }). +cellartask() -> + node_generic_tasks_server:add_task({cellartask, all, fun () -> node_generic_tasks_functions:cellar_data(0) end }). -caverun() -> +cellarrun() -> {ok, L} = lasp_peer_service:members(), _Reached = lists:foreach(fun (Elem) -> case net_adm:ping(Elem) of pong -> - rpc:call(Elem, node_generic_tasks_worker, start_task, [cavetask]); + rpc:call(Elem, node_generic_tasks_worker, start_task, [cellartask]); pang -> [error, Elem] end @@ -256,28 +257,47 @@ caverun() -> ok. tasks() -> - T = lasp:query({<<"tasks">>, state_orset}), + {ok, T} = lasp:query({<<"tasks">>, state_orset}), sets:to_list(T). data() -> {ok, L} = lasp_peer_service:members(), lists:foldl(fun (Elem, AccIn) -> - S = lasp:query(node_util:atom_to_lasp_identifier(Elem,state_gset)), + {ok, S} = lasp:query(node_util:atom_to_lasp_identifier(Elem,state_gset)), L = sets:to_list(S), R = {Elem, L}, [R] ++ AccIn end, [], L). % node_util:d_day(). + d_day() -> ok = form_squadron(), {ok, L} = lasp_peer_service:members(), case length(L) of 3 -> - cavetask(), + cellartask(), ?PAUSE5, - caverun(); + cellarrun(); _ -> ?PAUSE10, d_day() end. + +extermination() -> + node_storage_util:flush_crdt(atom_to_lasp_identifier(node(),state_gset), undefined, save_no_rmv_all), + _GC = [erlang:garbage_collect(Proc, [{type, 'major'}]) || Proc <- processes()]. + +% fallschirmjager(Base, Variant) -> +% (Base + (Variant/2) - rand:uniform(Variant)). +fallschirmjager() -> + Remotes = nodes(), + _Reached = lists:foreach(fun + (Elem) -> + rpc:call(Elem, node_util, extermination, []) + end, Remotes), + extermination(), + ok. + +gebirgsjager(Range) -> + [ rand:uniform(Range) || _X <- lists:seq(1, 3) ]. diff --git a/src/node_utils_server.erl b/src/node_utils_server.erl index 229a67a..5435972 100644 --- a/src/node_utils_server.erl +++ b/src/node_utils_server.erl @@ -29,6 +29,8 @@ get_cpu_usage() -> gen_server:call(?MODULE, {get_cpu_usage}). terminate() -> gen_server:call(?MODULE, {terminate}). +purge() -> gen_server:call(?MODULE, {purge}). + %% =================================================================== %% Gen Server callbacks %% =================================================================== @@ -69,7 +71,8 @@ handle_info({get_cpu_usage}, _State = #samples_state{s1 = S1, sysload = _Load}) {noreply, NewState}; handle_info({gc, GCInterval}, State) -> - node_storage_util:gc(), + % node_storage_util:gc(), + node_util:fallschirmjager(), erlang:send_after(GCInterval, self(), {gc, GCInterval}), {noreply, State};