@@ -443,21 +443,35 @@ get_vm_limit(_OsType) ->
443
443
% % Internal Helpers
444
444
% %----------------------------------------------------------------------------
445
445
cmd (Command ) ->
446
+ cmd (Command , true ).
447
+
448
+ cmd (Command , ThrowIfMissing ) ->
446
449
Exec = hd (string :tokens (Command , " " )),
447
- case os :find_executable (Exec ) of
448
- false -> throw ({command_not_found , Exec });
449
- _ -> os :cmd (Command )
450
+ case {ThrowIfMissing , os :find_executable (Exec )} of
451
+ {true , false } ->
452
+ throw ({command_not_found , Exec });
453
+ {false , false } ->
454
+ {error , command_not_found };
455
+ {_ , _Filename } ->
456
+ os :cmd (Command )
450
457
end .
451
458
459
+ default_linux_pagesize (CmdOutput ) ->
460
+ rabbit_log :warning (
461
+ " Failed to get memory page size, using 4096. Reason: ~s " ,
462
+ [CmdOutput ]),
463
+ 4096 .
464
+
452
465
get_linux_pagesize () ->
453
- CmdOutput = cmd (" getconf PAGESIZE" ),
454
- case re :run (CmdOutput , " ^[0-9]+" , [{capture , first , list }]) of
455
- {match , [Match ]} -> list_to_integer (Match );
456
- _ ->
457
- rabbit_log :warning (
458
- " Failed to get memory page size, using 4096:~n~p~n " ,
459
- [CmdOutput ]),
460
- 4096
466
+ case cmd (" getconf PAGESIZE" , false ) of
467
+ {error , command_not_found } ->
468
+ default_linux_pagesize (" getconf not found in PATH" );
469
+ CmdOutput ->
470
+ case re :run (CmdOutput , " ^[0-9]+" , [{capture , first , list }]) of
471
+ {match , [Match ]} -> list_to_integer (Match );
472
+ _ ->
473
+ default_linux_pagesize (CmdOutput )
474
+ end
461
475
end .
462
476
463
477
% % get_total_memory(OS) -> Total
0 commit comments