This is a method to run an ezstream icecast2 audio stream as a startup service within a Upstart init system. This method will also work for anything else which needs to run as a service.

I assume you have icecast2 installed and functioning: http://icecast.org/docs/icecast-2.2.0/basic-setup.html

Create a configuration file for ezstream in /etc/icecast2/ or in a project specific directory:

<ezstream>
    <url>http://localhost:8000/example.mp3</url>
    <sourcepassword>ICECAST_SOURCE_PASSWORD</sourcepassword>
    <format>MP3</format>
    <filename>/PATH/TO/MP3/FILE.mp3</filename>
    <svrinfoname>Example Stream</svrinfoname>
    <svrinfourl>localhost</svrinfourl>
    <svrinfogenre>ambient</svrinfogenre>
    <svrinfodescription>Example Stream</svrinfodescription>
    <svrinfobitrate>128</svrinfobitrate>
    <svrinfoquality>4.0</svrinfoquality>
    <svrinfochannels>2</svrinfochannels>
    <svrinfosamplerate>44100</svrinfosamplerate>
    <svrinfopublic>1</svrinfopublic>
</ezstream>

Then create an Upstart service startup script for the stream in /etc/init/ezstream-PROJECT.conf:

description "ezstream service for YOUR PROJECT"
author "YOUR NAME"

# Start the service on runlevel 2/3/4/5
start on runlevel [2345]

# Stop the service on runlevel 0/1/6
stop on runlevel [016]

script
	# Loop and wait for icecast2 to open port 8000. Change if you are using a different port.
	until nc -z localhost 8000; do
		echo "Waiting for icecast2 to start"
		sleep 1
	done
	# Start the ezstream instance with a unique name so multiple instances can be run.
	exec start-stop-daemon --start --name UNIQUE_SERVICE_NAME --exec /usr/bin/ezstream -- -c /PATH/TO/EZSTREAM/CONFIG.cfg
end script

More Upstart service configuration options here: Upstart Intro, Cookbook and Best Practises