summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVlad Ionescu <vlad@lshift.net>2009-10-29 19:14:31 +0000
committerVlad Ionescu <vlad@lshift.net>2009-10-29 19:14:31 +0000
commit80d77cb0fd6ca21a0624ae7263d0bf8b1f45c6aa (patch)
tree8b8145f4556d9cb651bd66877797c329c848404d
parentc00e5d2995c07c66c870f45792557f468c28ec79 (diff)
parenta612f02d45469a6afaa7308457c4bfd2ea8f782a (diff)
downloadrabbitmq-server-80d77cb0fd6ca21a0624ae7263d0bf8b1f45c6aa.tar.gz
merging bug21804 into default
-rw-r--r--scripts/rabbitmq-activate-plugins.bat4
-rw-r--r--scripts/rabbitmq-deactivate-plugins.bat4
-rwxr-xr-xscripts/rabbitmq-multi.bat12
-rwxr-xr-xscripts/rabbitmq-server2
-rwxr-xr-xscripts/rabbitmq-server.bat6
-rwxr-xr-xscripts/rabbitmq-service.bat8
-rwxr-xr-xscripts/rabbitmqctl.bat4
-rw-r--r--src/vm_memory_monitor.erl47
8 files changed, 66 insertions, 21 deletions
diff --git a/scripts/rabbitmq-activate-plugins.bat b/scripts/rabbitmq-activate-plugins.bat
index d639ff0e..e7aa7095 100644
--- a/scripts/rabbitmq-activate-plugins.bat
+++ b/scripts/rabbitmq-activate-plugins.bat
@@ -30,6 +30,8 @@ REM
REM Contributor(s): ______________________________________.
REM
+setlocal
+
if not exist "%ERLANG_HOME%\bin\erl.exe" (
echo.
echo ******************************
@@ -54,3 +56,5 @@ set RABBITMQ_EBIN_DIR=%~dp0..\ebin
-rabbit plugins_expand_dir \""%RABBITMQ_PLUGINS_EXPAND_DIR:\=/%"\" ^
-rabbit rabbit_ebin \""%RABBITMQ_EBIN_DIR:\=/%"\" ^
-extra %*
+
+endlocal
diff --git a/scripts/rabbitmq-deactivate-plugins.bat b/scripts/rabbitmq-deactivate-plugins.bat
index 71e60605..40155183 100644
--- a/scripts/rabbitmq-deactivate-plugins.bat
+++ b/scripts/rabbitmq-deactivate-plugins.bat
@@ -30,6 +30,10 @@ REM
REM Contributor(s): ______________________________________.
REM
+setlocal
+
set RABBITMQ_EBIN_DIR=%~dp0..\ebin
del /f "%RABBITMQ_EBIN_DIR%"\rabbit.rel "%RABBITMQ_EBIN_DIR%"\rabbit.script "%RABBITMQ_EBIN_DIR%"\rabbit.boot
+
+endlocal
diff --git a/scripts/rabbitmq-multi.bat b/scripts/rabbitmq-multi.bat
index 8abf13f1..8de18405 100755
--- a/scripts/rabbitmq-multi.bat
+++ b/scripts/rabbitmq-multi.bat
@@ -30,6 +30,8 @@ REM
REM Contributor(s): ______________________________________.
REM
+setlocal
+
if "%RABBITMQ_BASE%"=="" (
set RABBITMQ_BASE=%APPDATA%\RabbitMQ
)
@@ -61,5 +63,13 @@ if not exist "%ERLANG_HOME%\bin\erl.exe" (
exit /B
)
-"%ERLANG_HOME%\bin\erl.exe" -pa "%~dp0..\ebin" -noinput -hidden %RABBITMQ_MULTI_ERL_ARGS% -sname rabbitmq_multi -s rabbit_multi %RABBITMQ_MULTI_START_ARGS% -extra %*
+"%ERLANG_HOME%\bin\erl.exe" ^
+-pa "%~dp0..\ebin" ^
+-noinput -hidden ^
+%RABBITMQ_MULTI_ERL_ARGS% ^
+-sname rabbitmq_multi ^
+-s rabbit_multi ^
+%RABBITMQ_MULTI_START_ARGS% ^
+-extra %*
+endlocal
diff --git a/scripts/rabbitmq-server b/scripts/rabbitmq-server
index 08ceb27d..34904850 100755
--- a/scripts/rabbitmq-server
+++ b/scripts/rabbitmq-server
@@ -109,7 +109,7 @@ exec erl \
-os_mon start_cpu_sup true \
-os_mon start_disksup false \
-os_mon start_memsup false \
- -os_mon vm_memory_high_watermark 0.7 \
+ -os_mon vm_memory_high_watermark 0.4 \
-mnesia dir "\"${RABBITMQ_MNESIA_DIR}\"" \
${RABBITMQ_CLUSTER_CONFIG_OPTION} \
${RABBITMQ_SERVER_START_ARGS} \
diff --git a/scripts/rabbitmq-server.bat b/scripts/rabbitmq-server.bat
index 7cd3a33f..5b82ec15 100755
--- a/scripts/rabbitmq-server.bat
+++ b/scripts/rabbitmq-server.bat
@@ -30,6 +30,8 @@ REM
REM Contributor(s): ______________________________________.
REM
+setlocal
+
if "%RABBITMQ_BASE%"=="" (
set RABBITMQ_BASE=%APPDATA%\RabbitMQ
)
@@ -138,8 +140,10 @@ if exist "%RABBITMQ_CONFIG_FILE%.config" (
-os_mon start_cpu_sup true ^
-os_mon start_disksup false ^
-os_mon start_memsup false ^
--os_mon vm_memory_high_watermark 0.7 ^
+-os_mon vm_memory_high_watermark 0.4 ^
-mnesia dir \""%RABBITMQ_MNESIA_DIR%"\" ^
%CLUSTER_CONFIG% ^
%RABBITMQ_SERVER_START_ARGS% ^
%*
+
+endlocal
diff --git a/scripts/rabbitmq-service.bat b/scripts/rabbitmq-service.bat
index 68b557f1..0cc7bfa9 100755
--- a/scripts/rabbitmq-service.bat
+++ b/scripts/rabbitmq-service.bat
@@ -30,6 +30,8 @@ REM
REM Contributor(s): ______________________________________.
REM
+setlocal
+
if "%RABBITMQ_SERVICENAME%"=="" (
set RABBITMQ_SERVICENAME=RabbitMQ
)
@@ -51,7 +53,7 @@ if "%RABBITMQ_NODE_PORT%"=="" (
)
if "%ERLANG_SERVICE_MANAGER_PATH%"=="" (
- set ERLANG_SERVICE_MANAGER_PATH=C:\Program Files\erl5.5.5\erts-5.5.5\bin
+ set ERLANG_SERVICE_MANAGER_PATH=C:\Program Files\erl5.6.5\erts-5.6.5\bin
)
set CONSOLE_FLAG=
@@ -173,7 +175,7 @@ set ERLANG_SERVICE_ARGUMENTS= ^
-os_mon start_cpu_sup true ^
-os_mon start_disksup false ^
-os_mon start_memsup false ^
--os_mon vm_memory_high_watermark 0.7 ^
+-os_mon vm_memory_high_watermark 0.4 ^
-mnesia dir \""%RABBITMQ_MNESIA_DIR%"\" ^
%CLUSTER_CONFIG% ^
%RABBITMQ_SERVER_START_ARGS% ^
@@ -200,3 +202,5 @@ goto END
:END
+
+endlocal
diff --git a/scripts/rabbitmqctl.bat b/scripts/rabbitmqctl.bat
index 8a4e5445..512e8587 100755
--- a/scripts/rabbitmqctl.bat
+++ b/scripts/rabbitmqctl.bat
@@ -30,6 +30,8 @@ REM
REM Contributor(s): ______________________________________.
REM
+setlocal
+
if "%RABBITMQ_NODENAME%"=="" (
set RABBITMQ_NODENAME=rabbit
)
@@ -47,3 +49,5 @@ if not exist "%ERLANG_HOME%\bin\erl.exe" (
)
"%ERLANG_HOME%\bin\erl.exe" -pa "%~dp0..\ebin" -noinput -hidden %RABBITMQ_CTL_ERL_ARGS% -sname rabbitmqctl -s rabbit_control -nodename %RABBITMQ_NODENAME% -extra %*
+
+endlocal
diff --git a/src/vm_memory_monitor.erl b/src/vm_memory_monitor.erl
index 46c36af4..6da47933 100644
--- a/src/vm_memory_monitor.erl
+++ b/src/vm_memory_monitor.erl
@@ -70,6 +70,21 @@
}).
%%----------------------------------------------------------------------------
+
+-ifdef(use_specs).
+
+-spec(start_link/1 :: (float()) -> ('ignore' | {error, any()} | {'ok', pid()})).
+-spec(update/0 :: () -> 'ok').
+-spec(get_total_memory/0 :: () -> (non_neg_integer() | unknown)).
+-spec(get_check_interval/0 :: () -> non_neg_integer()).
+-spec(set_check_interval/1 :: (non_neg_integer()) -> 'ok').
+-spec(get_vm_memory_high_watermark/0 :: () -> float()).
+-spec(set_vm_memory_high_watermark/1 :: (float()) -> 'ok').
+
+-endif.
+
+
+%%----------------------------------------------------------------------------
%% gen_server callbacks
%%----------------------------------------------------------------------------
@@ -80,9 +95,10 @@ init([MemFraction]) ->
TotalMemory =
case get_total_memory() of
unknown ->
- rabbit_log:warning("Unknown total memory size for your OS ~p. "
- "Assuming memory size is ~p bytes.~n",
- [os:type(), ?MEMORY_SIZE_FOR_UNKNOWN_OS]),
+ rabbit_log:warning(
+ "Unknown total memory size for your OS ~p. "
+ "Assuming memory size is ~pMB.~n",
+ [os:type(), trunc(?MEMORY_SIZE_FOR_UNKNOWN_OS/1048576)]),
?MEMORY_SIZE_FOR_UNKNOWN_OS;
M -> M
end,
@@ -184,8 +200,8 @@ start_timer(Timeout) ->
%% in big trouble anyway.
get_vm_limit() ->
case erlang:system_info(wordsize) of
- 4 -> 2147483648; %% 2 GB for 32 bits 2^31
- 8 -> 140737488355328 %% 128 TB for 64 bits 2^47
+ 4 -> 4294967296; %% 4 GB for 32 bits 2^32
+ 8 -> 281474976710656 %% 256 TB for 64 bits 2^48
%% http://en.wikipedia.org/wiki/X86-64#Virtual_address_space_details
end.
@@ -195,15 +211,19 @@ get_mem_limit(MemFraction, TotalMemory) ->
%%----------------------------------------------------------------------------
%% Internal Helpers
%%----------------------------------------------------------------------------
+cmd(Command) ->
+ Exec = hd(string:tokens(Command, " ")),
+ case os:find_executable(Exec) of
+ false -> throw({command_not_found, Exec});
+ _ -> os:cmd(Command)
+ end.
%% get_total_memory(OS) -> Total
%% Windows and Freebsd code based on: memsup:get_memory_usage/1
-%% Original code was part of OTP and released under "Erlang Public
-%% License".
+%% Original code was part of OTP and released under "Erlang Public License".
-%% Darwin: Uses vm_stat command.
get_total_memory({unix,darwin}) ->
- File = os:cmd("/usr/bin/vm_stat"),
+ File = cmd("/usr/bin/vm_stat"),
Lines = string:tokens(File, "\n"),
Dict = dict:from_list(lists:map(fun parse_line_mach/1, Lines)),
[PageSize, Inactive, Active, Free, Wired] =
@@ -212,15 +232,11 @@ get_total_memory({unix,darwin}) ->
'Pages wired down']],
PageSize * (Inactive + Active + Free + Wired);
-%% FreeBSD: Look in /usr/include/sys/vmmeter.h for the format of
-%% struct vmmeter
get_total_memory({unix,freebsd}) ->
PageSize = freebsd_sysctl("vm.stats.vm.v_page_size"),
PageCount = freebsd_sysctl("vm.stats.vm.v_page_count"),
PageCount * PageSize;
-%% Win32: Find out how much memory is in use by asking the
-%% os_mon_sysinfo process.
get_total_memory({win32,_OSname}) ->
[Result|_] = os_mon_sysinfo:get_mem_info(),
{ok, [_MemLoad, TotPhys, _AvailPhys,
@@ -228,7 +244,6 @@ get_total_memory({win32,_OSname}) ->
io_lib:fread("~d~d~d~d~d~d~d", Result),
TotPhys;
-%% Linux: Look in /proc/meminfo
get_total_memory({unix, linux}) ->
File = read_proc_file("/proc/meminfo"),
Lines = string:tokens(File, "\n"),
@@ -236,7 +251,7 @@ get_total_memory({unix, linux}) ->
dict:fetch('MemTotal', Dict);
get_total_memory({unix, sunos}) ->
- File = os:cmd("/usr/sbin/prtconf"),
+ File = cmd("/usr/sbin/prtconf"),
Lines = string:tokens(File, "\n"),
Dict = dict:from_list(lists:map(fun parse_line_sunos/1, Lines)),
dict:fetch('Memory size', Dict);
@@ -287,7 +302,7 @@ parse_line_sunos(Line) ->
end.
freebsd_sysctl(Def) ->
- list_to_integer(os:cmd("/sbin/sysctl -n " ++ Def) -- "\n").
+ list_to_integer(cmd("/sbin/sysctl -n " ++ Def) -- "\n").
%% file:read_file does not work on files in /proc as it seems to get
%% the size of the file first and then read that many bytes. But files