# Upstart script for yrmcds

description     "yrmcds"

start on net-device-up
stop on runlevel [!2345]

respawn

umask 077
limit nofile 100000 100000
limit memlock unlimited unlimited
chdir /tmp

pre-start script
    [ -d /var/tmp/yrmcds ] || mkdir /var/tmp/yrmcds
    chmod 700 /var/tmp/yrmcds
    chown nobody:nogroup /var/tmp/yrmcds
    rm -f /var/tmp/yrmcds/*

    # make sure keepalived init script was disabled.
    # ex) sudo update-rc.d keepalived disable
    /etc/init.d/keepalived start
    sleep 5
end script

post-stop script
    /etc/init.d/keepalived stop

    # sleep a while to hand-off VIP
    sleep 5
end script

exec /usr/local/sbin/yrmcdsd
