Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ ssl/*
bin/.nodester.config
*.log
*.log.*
*.log*.gz
node_modules
logs
public/static/node-*
30 changes: 26 additions & 4 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,20 @@ http://nodester.com

var express = require('express'),
url = require('url'),
sys = require('sys'),
config = require('./config'),
middle = require('./lib/middle');

process.on('uncaughtException', function(err) {
console.log(err.stack);
});

var daemon = require('daemon');
// daemon.setreuid(config.opt.userid);
var myapp = express.createServer();
var gzippo = require('gzippo');

myapp.configure(function() {
myapp.use(express.bodyParser());
myapp.use(express.static(config.opt.public_html_dir));
// myapp.use(express.static(config.opt.public_html_dir));
myapp.use(gzippo.staticGzip(config.opt.public_html_dir));
myapp.use(middle.error());
});

Expand Down Expand Up @@ -148,6 +147,29 @@ myapp.post('/appdomains', middle.authenticate, middle.authenticate_app, domains.
myapp.delete('/appdomains', middle.authenticate, middle.authenticate_app, domains.delete);
myapp.get('/appdomains', middle.authenticate, domains.get);

// Redis DB support
var redisdb = require('./lib/redisdb');
// GET will retrieve details of a redis db, read the log/config files or start/stop/restart the database
// POST will create a named redis db instance
// DELETE will remove a named redis db instance
// curl -X GET -u "testuser:123" http://localhost:4001/redis/<dbname>
// curl -X GET -u "testuser:123" http://localhost:4001/redis/logs/<dbname>
// curl -X GET -u "testuser:123" http://localhost:4001/redis/config/<dbname>
// curl -X GET -u "testuser:123" http://localhost:4001/redis/start/<dbname>
// curl -X GET -u "testuser:123" http://localhost:4001/redis/stop/<dbname>
// curl -X GET -u "testuser:123" http://localhost:4001/redis/restart/<dbname>
// curl -X POST -u "testuser:123" -d "dbname=test" http://localhost:4001/redis
// curl -X DELETE -u "testuser:123" -d "dbname=test" http://localhost:4001/redis
myapp.get('/redis/:dbname', middle.authenticate, middle.authenticate_redisdb, redisdb.get);
myapp.get('/redis', middle.authenticate, redisdb.get_all);
myapp.get('/redis/start/:dbname', middle.authenticate, middle.authenticate_redisdb, redisdb.redis_start);
myapp.get('/redis/stop/:dbname', middle.authenticate, middle.authenticate_redisdb, redisdb.redis_stop);
myapp.get('/redis/restart/:dbname', middle.authenticate, middle.authenticate_redisdb, redisdb.redis_restart);
myapp.get('/redis/logs/:dbname', middle.authenticate, middle.authenticate_redisdb, redisdb.logs);
myapp.get('/redis/config/:dbname', middle.authenticate, middle.authenticate_redisdb, redisdb.config);
myapp.post('/redis', middle.authenticate, redisdb.post);
myapp.delete('/redis', middle.authenticate, middle.authenticate_redisdb, redisdb.delete);


myapp.use(express.errorHandler({
showStack: true
Expand Down
34 changes: 0 additions & 34 deletions bin/app_start.sh

This file was deleted.

25 changes: 0 additions & 25 deletions bin/app_stop.sh

This file was deleted.

15 changes: 0 additions & 15 deletions bin/forever-app

This file was deleted.

15 changes: 0 additions & 15 deletions bin/forever-proxy

This file was deleted.

39 changes: 0 additions & 39 deletions bin/proxy_start.sh

This file was deleted.

25 changes: 0 additions & 25 deletions bin/proxy_stop.sh

This file was deleted.

30 changes: 24 additions & 6 deletions bin/proxyd
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ APP="Proxy"
DATE=$(date)
LOG="proxyd.log"

# Stashboard bin path
STASH_PATH=/home/hajo/bin

# used to append the current date to the archive name
DATE2=$(date +"%Y%m%d")

if [ -z "$USER" ]; then
USER=root
fi

cd /var/cloudnode/nodester
#echo "$DATE Proxy control started with command $1 as user $USER" | tee -a $LOG
echo "$DATE Proxy control started with command $1 as user $USER" | tee -a $LOG

get_pid()
{
Expand All @@ -26,8 +32,18 @@ case "$1" in
fi
get_pid
if [ -z "$PID" ]; then
/usr/local/node-v0.4.0/node proxy/proxy.js > proxy.log | tee -a $LOG &
# save log file
mv proxy.log proxy.log.$DATE2
# start proxy
# /usr/local/node-v0.4.0/node proxy/proxy.js > proxy.log | tee -a $LOG &
# /usr/local/node-v0.6.11/node proxy/proxy.js > proxy.log | tee -a $LOG &
node proxy/proxy.js > proxy.log | tee -a $LOG &
echo "$APP started" | tee -a $LOG

# log event
if [ "$2" = "notify" ]; then
python ${STASH_PATH}/stashboard-client/cloudnode-status.py -t cloudnode-proxy -s up -m "online with all services"
fi
else
echo "$APP is already running ($PID)" | tee -a$LOG
fi
Expand All @@ -38,6 +54,12 @@ case "$1" in
if [ -n "$PID" ]; then
kill -9 $PID
echo "$APP stopped ($PID)" | tee -a $LOG

# log event
if [ "$2" = "notify" ]; then
python ${STASH_PATH}/stashboard-client/cloudnode-status.py -t cloudnode-proxy -s down -m "The Cloudnode proxy service is experiencing a service disruption"
fi

else
echo "$APP is not running ($PID)" | tee -a $LOG
fi
Expand All @@ -49,9 +71,7 @@ case "$1" in
exit
fi
$0 stop
$0 stat
sleep 1
$0 stat
$0 start
$0 stat
;;
Expand All @@ -71,5 +91,3 @@ case "$1" in
;;

esac


3 changes: 2 additions & 1 deletion bin/start_hosted_apps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ cd `dirname $0`
wait
source ./.nodester.config

node $APP_DIR/scripts/start_hosted_apps.js start "$@"
ulimit -n 2048
sudo -u cloudnode /usr/local/node-v0.4.12/node $APP_DIR/scripts/start_hosted_apps.js start "$@"
2 changes: 1 addition & 1 deletion bin/stop_hosted_apps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ cd `dirname $0`
wait
source ./.nodester.config

node $APP_DIR/scripts/start_hosted_apps.js stop "$@"
/usr/local/node-v0.4.12/node $APP_DIR/scripts/start_hosted_apps.js stop "$@"
2 changes: 1 addition & 1 deletion bin/top
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node

var exec = require('child_process').exec;
var cmd = "ps aux | awk '/launch_chroot/ && !/awk/ {print $3,$4,$2,$5,$6,$10,$13}' | sort -r | head -n 20";
var cmd = "ps aux | awk '/launch_/ {print $3,$4,$2,$5,$6,$10,$13}' | sort -r | head -n 20";

require('colors');

Expand Down
32 changes: 32 additions & 0 deletions deps/cloudnode-proxy/proxy-error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Proxy error extension for Cloudnode
*
* This extension provides web statistics using Redis counters
*/

"use strict";

var errorHtml = '<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">' +
'<head>' +
'<title id="title">{title}</title>' +
'<style stype="text/css">' +
'html { font-family: Arial,Helvetica,sans-serif; }' +
'div { width: 100%; text-align: center; margin-top: 230px; color: #909090; }' +
'</style>' +
'</head>' +
'<body>' +
'<div>' +
'<img src="https://cloudno.de/static/img/cloudnode-logo2-light.png" alt="logo" />' +
'<h1>{code}</h1>' +
'<h3>{error}</h3>' +
'</div>' +
'</body>' +
'</html>';

/**
* Outputs a customized error page
*/
exports.getErrorPage = function(title, code, error) {
return errorHtml.replace('{title}', title).replace('{code}', code).replace('{error}', error);
};

Loading