On 10/02/2015 04:08 μμ, Yosef Amir wrote:
> Hi ,
> Currently, When HAproxy failed to initial (E.G invalid haproxy.cfg
> options) it write the error to the screen.
> Is there option that HAproxy will write to log file when it failed to
> initial?
>  


Just think a bit as developer who writes the config parser code and
tries to solve the following problem:
In order to log messages I need to read my from configuration the
appropriate setting but I failed to read the configuration because it
didn't pass my sanity check.



pseudo code

$start > log 2>&1
if [[ $? -ne 0 ]]; then
  $some_kind_of_monitor_alert_mail_smapper 'broken conf in place'
fi

If you use puppet/chef/etc you can do the following
pseudo code

clean_conf_temp_file
generate_conf_to_temp_file
haproxy -f <file_tmp> -c
if [[ $? -ne 0]]; then
  puppet_raise_error
else
  mv_generated_conf_temp_file_to_real_file
fi

at the some time you have your monitor system to check for the existence
of that temp file and alert if it is found

I have implemented this logic in puppet/nagios/nrpe and saved us few
times as you can run into state where conf file is broken and you cant
start again haproxy. The logic here is to always have a valid
configuration present so we can reload/restart the process.

> Example:
> [root@proxy-au2 ~]# haproxy -f /usr/cti/conf/haproxy/haproxy.cfg
> [ALERT] 040/172141 (12460) : Starting proxy HAProxy_DirectDeposit:
> cannot bind socket [0.0.0.0:50025]
>  
>  
> In this example: HAProxy alert - cannot bind socket.
> How can I get this kind of alerts that stop HAProxy from starting to
> write log file ?
>


Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to