2 # This script installs an app for nodejs: the app intended is the paypal app
3 # and it is configured to connect to the mongodb server
4 # The environment variables github_url and mongodb_ip are expected to be set up
5 export app_dir=/opt/app
6 git clone $github_url /opt/app
7 if [ -f /opt/app/package.json ]; then
8 cd /opt/app/ && npm install
9 sed -i "s/localhost/$mongodb_ip/" config.json
12 cat > /etc/init/nodeapp.conf <<EOS
13 description "node.js app"
15 start on (net-device-up
18 stop on runlevel [!2345]
25 export NODE_PATH=/usr/lib/node
26 exec /usr/bin/node ${app_dir}/app.js >> /var/log/nodeapp.log 2>&1 &