description  "OVSvApp Agent"
author       "Hewlett-Packard Enterprise"

start on (net-device-up
          and local-filesystems
          and runlevel [2345])

stop on runlevel [016]

kill timeout 30

respawn
respawn limit 30 60

env LANG=en_US.UTF-8
env AGENTDIR=/opt/stack/networking-vsphere
env logfile=/var/log/neutron/ovsvapp-agent/monitor.log

pre-start script
    mkdir -p /var/log/neutron/ovsvapp-agent
    if [ ! -f $logfile ]; then
       touch $logfile
    fi
    chown -R neutron:neutron /var/log/neutron/ovsvapp-agent

    # Check and start the openvswitch-switch process if its stopped.
    status openvswitch-switch | if  grep -q  'stop/waiting' ; then
            start openvswitch-switch || true
        fi
end script

script
  export PYTHONPATH=$AGENTDIR:/usr/share/pyshared/neutron
  exec start-stop-daemon --signal INT --start --chuid neutron --exec /usr/bin/neutron-ovsvapp-agent -- --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ovsvapp_agent.ini --log-file=/var/log/neutron/ovsvapp-agent/ovsvapp_agent.log
end script
