Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    HAProxy service control script not generating correctly.

    Scheduled Pinned Locked Moved pfSense Packages
    4 Posts 2 Posters 1.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P Offline
      pffan
      last edited by

      Using pfsense 2.2.6-RELEASE (amd64)  This occurs with both haproxy-1_5 and haproxy-devel packages.

      I noticed that haproxy wasn't stopping when I clicked the stop button.  This was found in the system logs:

       php-fpm[86316]: /status_services.php: The command '/usr/local/etc/rc.d/haproxy.sh stop' returned exit code '1', the output was 'haproxy not running?'
      

      HAProxy is indeed running:

      $ ps -A | grep haproxy
      14236  -  S         0:00.00 sh -c ps -A | grep haproxy 2>&1
      14537  -  S         0:00.00 grep haproxy
      39515  -  Ss        0:00.01 /usr/local/sbin/haproxy -f /var/etc/haproxy/haproxy
      

      Let's look at the script:

      $ cat /usr/local/etc/rc.d/haproxy.sh
      #!/bin/sh
      
      # PROVIDE: haproxy
      # REQUIRE: LOGIN
      # KEYWORD: FreeBSD
      
      . /etc/rc.subr
      
      name="haproxy"
      rcvar="${name}_enable"
      command="/usr/pbi/haproxy-devel-amd64/sbin/haproxy"
      haproxy_enable=${haproxy-"YES"}
      
      start_cmd="haproxy_start"
      stop_postcmd="haproxy_stop"
      check_cmd="haproxy_check"
      extra_commands="check"
      
      load_rc_config $name
      
      haproxy_start () {
              echo "Starting haproxy."
              /usr/bin/env \
              PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
      		/usr/local/bin/php -q -d auto_prepend_file=config.inc < <endoff<br>require_once("globals.inc");		
      			require_once("functions.inc");
      			require_once("haproxy.inc");
      			haproxy_configure();
      		?>
      ENDOFF
      }
      
      haproxy_check () {
              echo "Checking haproxy."
              /usr/bin/env \
              PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
      		/usr/local/bin/php -q -d auto_prepend_file=config.inc < <endoff<br>require_once("globals.inc");		
      			require_once("functions.inc");
      			require_once("haproxy.inc");
      			haproxy_check_run(0);
      		?>
      ENDOFF
      }
      
      haproxy_stop () {
              echo "Stopping haproxy."
              killall haproxy
      }
      
      run_rc_command "$1"</endoff<br></endoff<br>
      

      I don't think that php code is supposed to be there.  It seems to me something went wrong when generating this script.  This script is generated during package installation, is it not?

      Again, the result is the same whether I use haproxy-devel or haproxy-1_5 packages.

      This isn't a huge deal right now as this is only my test rig but if anyone has a fix for this I'd be very grateful.  I will continue looking at the package to see if I can find where this script is generated and identify any errors in php.  I'll update with my findings.

      1 Reply Last reply Reply Quote 0
      • P Offline
        pffan
        last edited by

        It seems the php code is supposed to be there.  I'll start digging through the includes tomorrow.

        Learning much but no progress.  Still hoping someone can chime in with their insights.

        1 Reply Last reply Reply Quote 0
        • jimpJ Offline
          jimp Rebel Alliance Developer Netgate
          last edited by

          Is there an actual problem? Or are you just chasing that log message?

          The file looks right to me, it's executing that PHP code inline to configure HAproxy.

          The only thing that log message indicates is that it tried to run the stop command when it wasn't running yet, which could be as simple as something in the code calling "restart" on it without checking if it's running first.

          Unless you have a problem it seems like this is just harmless log spam…

          Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

          Need help fast? Netgate Global Support!

          Do not Chat/PM for help!

          1 Reply Last reply Reply Quote 0
          • P Offline
            pffan
            last edited by

            Revisiting this finally.

            The problem I  had was that the haproxy service wouldn't stop when commanded.  This seems to be due to this instance running on a carp slave.  Apparently leaving the "carp monitor: Monitor carp interface and only run haproxy on the firewall which is MASTER." configuration option unused means "always run haproxy on the slave and don't let it stop".  I was expecting to have two running instances of haproxy that synced sessions so I could monitor these services on both boxes.  I suppose this is an unsupported configuration.  I'll figure out something another way to do what I need.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.