Update set of scripts for mongodb and nodejs

This set of scripts is used in the first 2 nodes for the monitoring
use case.  They install mongodb and nodejs, configure and start them.
The config script for nodejs is designed for the paypal nodejs app:
https://github.com/paypal/rest-api-sample-app-nodejs.git
It configures the link to the mongodb database for the app.
The scripts have been validated by deploying to 2 VM's using Heat
templates.

Implements: blueprint translate-tosca-monitoring-usecase
Change-Id: I08d20ed40bbe23a2193ba1892d6d23b4bd7804f6
This commit is contained in:
Ton Ngo
2015-03-31 15:25:44 -07:00
parent 04a9a6fa22
commit 6c07f2f873
7 changed files with 35 additions and 29 deletions

View File

@@ -1,2 +1,7 @@
#!/bin/bash
stop mongodb
#!/bin/sh -x
# Edit the file /etc/mongodb.conf, update with real IP of Mongo server
# This script configures the mongodb server to export its service on
# the server IP
# bind_ip = 127.0.0.1 -> bind_ip = <IP for Mongo server>
# The environment variable mongodb_ip is expected to be set up
sed -i "s/127.0.0.1/$mongodb_ip/" /etc/mongodb.conf

View File

@@ -1,2 +1,4 @@
#!/bin/bash
#!/bin/sh -x
# This script installs mongodb
apt-get update
apt-get install -y mongodb

View File

@@ -1,2 +1,3 @@
#!/bin/bash
start mongodb
#!/bin/sh -x
# This script starts mongodb
restart mongodb

View File

@@ -1,24 +1,28 @@
#!/bin/bash
#!/bin/sh -x
# This script installs an app for nodejs: the app intended is the paypal app
# and it is configured to connect to the mongodb server
# The environment variables github_url and mongodb_ip are expected to be set up
export app_dir=/opt/app
git clone $github_url /opt/app
if [ -f /opt/app/package.json ]
cd /opt/app/ && npm install
if [ -f /opt/app/package.json ]; then
cd /opt/app/ && npm install
sed -i "s/localhost/$mongodb_ip/" config.json
fi
cat > /etc/init/nodeapp.conf <<EOS
description "node.js app"
start on (net-device-up
and local-filesystems
and runlevel [2345])
and local-filesystems
and runlevel [2345])
stop on runlevel [!2345]
expect fork
respawn
script
export HOME=/
export NODE_PATH=/usr/lib/node
exec /usr/bin/node ${app_dir}/server.js >> /var/log/nodeapp.log 2>&1 &
export HOME=/
export NODE_PATH=/usr/lib/node
exec /usr/bin/node ${app_dir}/app.js >> /var/log/nodeapp.log 2>&1 &
end script
EOS

View File

@@ -1,4 +1,5 @@
#!/bin/bash
add-apt-repository ppa: chris-lea/node.js
#!/bin/sh -x
# This script installs nodejs and the prereq
add-apt-repository ppa:chris-lea/node.js
apt-get update
apt-get install -y nodejs build-essential curl git npm
apt-get install -y nodejs build-essential

View File

@@ -1,8 +0,0 @@
#!/bin/bash
cat > /opt/node/config.js<<EOF
{
"host": "${host}"
, "port": ${port}
}
EOF

View File

@@ -1,2 +1,3 @@
#!/bin/bash
start nodeapp
#!/bin/sh -x
# This script starts the nodejs application
start nodeapp