Skip to content

Commit 2b717a8

Browse files
committed
Only start os_mon application on win32
`os_mon` is only used on `win32` systems, so there is no need to start it on `unix` systems. In addition, `os_mon` can pollute the log files with memory high watermark messages that can be confused with those emitted by RabbitMQ's memory monitor. At some point, RabbitMQ _should_ use `os_mon` for disk and memory monitoring, but that day is a ways away. * Ensure that `os_mon` settings are present upon boot * On `win32` systems, enable `memsup` before starting `os_mon` app
1 parent 81caabc commit 2b717a8

File tree

4 files changed

+33
-9
lines changed

4 files changed

+33
-9
lines changed

deps/rabbit/Makefile

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,21 @@ define PROJECT_ENV
114114
%% interval at which connection/channel tracking executes post operations
115115
{tracking_execution_timeout, 15000},
116116
{stream_messages_soft_limit, 256},
117-
{track_auth_attempt_source, false},
118-
{credentials_obfuscation_fallback_secret, <<"nocookie">>},
119-
{dead_letter_worker_consumer_prefetch, 32},
120-
{dead_letter_worker_publisher_confirm_timeout, 180000},
121-
{vhost_process_reconciliation_run_interval, 30},
122-
%% for testing
123-
{vhost_process_reconciliation_enabled, true},
124-
{license_line, "Licensed under the MPL 2.0. Website: https://rabbitmq.com"}
117+
{track_auth_attempt_source, false},
118+
{credentials_obfuscation_fallback_secret, <<"nocookie">>},
119+
{dead_letter_worker_consumer_prefetch, 32},
120+
{dead_letter_worker_publisher_confirm_timeout, 180000},
121+
{vhost_process_reconciliation_run_interval, 30},
122+
%% for testing
123+
{vhost_process_reconciliation_enabled, true},
124+
{license_line, "Licensed under the MPL 2.0. Website: https://rabbitmq.com"},
125+
{os_mon, start_cpu_sup, false},
126+
{os_mon, start_disksup, false},
127+
{os_mon, start_memsup, false}
125128
]
126129
endef
127130

128-
LOCAL_DEPS = sasl os_mon inets compiler public_key crypto ssl syntax_tools xmerl
131+
LOCAL_DEPS = sasl inets compiler public_key crypto ssl syntax_tools xmerl
129132

130133
BUILD_DEPS = rabbitmq_cli
131134
DEPS = ranch cowlib rabbit_common amqp10_common rabbitmq_prelaunch ra sysmon_handler stdout_formatter recon redbug observer_cli osiris syslog systemd seshat horus khepri khepri_mnesia_migration cuttlefish gen_batch_server

deps/rabbit/src/rabbit_disk_monitor.erl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ init([Limit]) ->
139139
{unix, _} ->
140140
start_portprogram();
141141
{win32, _OSname} ->
142+
%% Note: os_mon is not automatically started as it is only
143+
%% used on win32 for the time being. Rather than start it
144+
%% on all systems, we start it here.
145+
ok = rabbit_misc:ensure_os_mon_memsup(),
142146
not_used
143147
end,
144148
State3 = State2#state{port=Port, os=OS},

deps/rabbit/src/vm_memory_monitor.erl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,12 @@ init_state_by_os(State0 = #state{os_type = {unix, linux}, os_pid = OsPid}) ->
275275
PageSize = get_linux_pagesize(),
276276
ProcFile = io_lib:format("/proc/~ts/statm", [OsPid]),
277277
State0#state{page_size = PageSize, proc_file = ProcFile};
278+
init_state_by_os(State = #state{os_type = {win32, _}}) ->
279+
%% Note: os_mon is not automatically started as it is only
280+
%% used on win32 for the time being. Rather than start it
281+
%% on all systems, we start it here.
282+
ok = rabbit_misc:ensure_os_mon_memsup(),
283+
State;
278284
init_state_by_os(State) ->
279285
State.
280286

deps/rabbit_common/src/rabbit_misc.erl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@
9090
-export([remote_sup_child/2]).
9191
-export([for_each_while_ok/2, fold_while_ok/3]).
9292

93+
-export([ensure_os_mon_memsup/0]).
94+
9395
%% Horrible macro to use in guards
9496
-define(IS_BENIGN_EXIT(R),
9597
R =:= noproc; R =:= noconnection; R =:= nodedown; R =:= normal;
@@ -1615,3 +1617,12 @@ fold_while_ok(Fun, Acc0, [Elem | Rest]) ->
16151617
end;
16161618
fold_while_ok(_Fun, Acc, []) ->
16171619
{ok, Acc}.
1620+
1621+
ensure_os_mon_memsup() ->
1622+
ensure_os_mon_memsup(os:type()).
1623+
1624+
ensure_os_mon_memsup({win32, _}) ->
1625+
ok = application:set_env(os_mon, start_memsup, true),
1626+
ok = application:ensure_started(os_mon);
1627+
ensure_os_mon_memsup(_) ->
1628+
ok.

0 commit comments

Comments
 (0)