description "Margarine Daemon: <%= @service %>"
author "Alex Brandt <alunduil@alunduil.com>"

setuid <%= node['margarine']['user'] %>
setgid <%= node['margarine']['group'] %>

console log

start on ((
     started network-interface
 or  started network-manager
 or  started networking)
 and started rsyslog)

stop on runlevel [!345]

<% if node['margarine']['install']['method'] =~ /source|vagrant/ -%>
env PYTHONPATH=<%= node['margarine']['install']['path'] %>
<% end -%>
exec <%= node['margarine']['install']['method'] =~ /source|vagrant/ ? node['margarine']['install']['path'] : '' %>/bin/<%= @service %>

description "Margarine Daemon: <%= @service %>"
author "Alex Brandt <alunduil@alunduil.com>"

setuid <%= node['margarine']['user'] %>
setgid <%= node['margarine']['group'] %>

console log

start on (
  (
       started network-services
    or started networking
  )
  and started rsyslog
)

stop on (
     stopping network-services
  or stopping networking
)

<% if node['margarine']['install']['method'] =~ /source|vagrant/ -%>
env PYTHONPATH=<%= node['margarine']['install']['path'] %>
<% end -%>
exec <%= node['margarine']['install']['method'] =~ /source|vagrant/ ? node['margarine']['install']['path'] : '' %>/bin/<%= @service %>

Simplify the start on and stop on event handlers.
Simplify the start on and stop on event handlers.

After looking through the upstart documentation for a few minutes I've
been able to simplify the event handlers for our upstart jobs to only
require networking and logging.  When networking stops we stop our
service (it will restart when networking is started again).
