[wplug] Anyone out there really understand upstart...?

Martin James Gehrke martin at teamgehrke.com
Fri Mar 21 16:31:06 EDT 2014


the most fundamental upstart script would be

# Ubuntu upstart file at /etc/init/yourservice.conf

pre-start script
    mkdir -p /var/log/yourcompany/
end script

post-stop script
    #do some cleanup
end script

respawn
respawn limit 15 5

start on runlevel [2345]
stop on runlevel [06]

script
su - youruser -c "NODE_ENV=test exec
/var/www/yourcompany/yourproject/yourservice.js 2>&1" >>
/var/log/yourcompany/yourservice.log
end script

You don't have to worry about the start and stop code in the upstart
init file, this would be handeled in the script or through upstart
itself.



On Wed, Mar 19, 2014 at 5:29 PM, Pat Barron <pat at lectroid.com> wrote:

> OK, I am trying to take something I normally would have done using a
> "traditional" init.d script, and translate it into similar function in
> upstart.  And I'm apparently just not getting it...
>
> The "traditional" script would look something like:
>
>     #!/bin/sh
>
>     case "$0" in
>         *start)
>            /run/some/program
>            ;;
>         *stop)
>            /run/different/program
>            ;;
>         *)
>            echo $"Usage: $0 {start|stop}"
>            exit 1
>            ;;
>         esac
>
>
> Which would be put into /etc/init.d, and then links created in the
> /etc/rc?.d directories with link names that look like "SnnSCRIPTNAME"
> and "KnnSCRIPTNAME", to make the "start" and "stop" actions run as
> appropriate.
>
> The programs being run perform a simple task to start up (or shut down,
> as appropriate) a service daemon, and then they exit.
>
> I just can't figure out how to do basically the same thing using upstart
> (on RHEL 6), and I don't see anything in the documentation that would
> guide me.  You'd think this would be a common use case (migrating from a
> traditional init.d script to upstart) that they'd have a canned
> procedure for, but if there is one, I'm not finding it...
>
> Any advice?
>
> Thanks!
> --Pat.
> _______________________________________________
> wplug mailing list
> wplug at wplug.org
> http://www.wplug.org/mailman/listinfo/wplug
>


More information about the wplug mailing list