#!/bin/sh

# get pid that listen on a port
function get_pid_port()
{
  port=$1
  lsof -i | grep ":$port (LISTEN)" | sed 's:[^ ]\+[ ]\+\([0-9]\+\).*:\1:'
}

# kill the pid that listens on port
function kill_pid_port()
{
  pid=$1
  port=$2
  kill -TERM $pid 
  sleep 1
  lsof -i | grep ":$port (LISTEN)" && return 1 || return 0
}

function httpd_restart
{
  ps -A | grep httpd
  kill -HUP $(cat $AREX_RUN_DIR/pid)
  # wait for httpd to settle down
  sleep 2
  ps -A | grep httpd
}

