updating nodebb executable so that it sends a NODE_ENV environment

variable in, and modified app.js and redis lib to read it.
v1.18.x
Julian Lam 12 years ago
parent f91e0848ee
commit 4d99870063

@ -4,6 +4,9 @@ var fs = require('fs'),
utils = require('./public/src/utils.js'),
args = {};
// Runtime environment
global.env = process.env.NODE_ENV || 'production',
// Parse any passed-in arguments
process.argv.slice(2).forEach(function(value) {
if (value.slice(0, 2) === '--') {

@ -1,4 +1,4 @@
#!/bin/bash
clear
echo "Launching NodeBB"
supervisor --extensions 'node|js|tpl' -- app $1
echo "Launching NodeBB in \"development\" mode"
NODE_ENV=development supervisor --extensions 'node|js|tpl' -- app $1

@ -1,8 +1,5 @@
(function(RedisDB) {
var PRODUCTION = false,
ERROR_LOGS = true,
redis = require('redis'),
var redis = require('redis'),
utils = require('./../public/src/utils.js');
RedisDB.exports = redis.createClient(global.config.redis.port, global.config.redis.host);
@ -13,14 +10,14 @@
RedisDB.exports.handle = function(error) {
if (error !== null) {
if (PRODUCTION === false) {
if (global.env !== 'production') {
console.log("################# ERROR LOG ####################");
console.log(error);
console.log(arguments.callee.name);
console.log("################# ERROR LOG ####################");
throw new Error('RedisDB Error: ' + error);
} else if (ERROR_LOGS === true) {
console.log('RedisDB Error: ' + error);
throw new Error(error);
} else {
console.log(error);
}
}
}

@ -753,11 +753,15 @@ var utils = require('./../public/src/utils.js'),
};
User.go_online = function(uid) {
RDB.sadd('users:online', uid);
RDB.sadd('users:online', uid, function(err) {
if (err) RDB.handle(err);
});
};
User.go_offline = function(uid) {
RDB.srem('users:online', uid);
RDB.srem('users:online', uid, function(err) {
if (err) RDB.handle(err);
});
};

@ -292,12 +292,8 @@ var express = require('express'),
app.get('/api/:method/:id*', api_method);
app.all('/test', function(req, res) {
var RDB = require('./redis.js');
RDB.lpush('administrators', 1, function(err, data) {
// console.log(err, data);
res.send();
});
});
//START TODO: MOVE TO GRAPH.JS

@ -55,11 +55,13 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }),
var hs = socket.handshake;
var uid = users[hs.sessionID];
// if (uid > 0) {
userSockets[uid] = userSockets[uid] || [];
userSockets[uid].push(socket);
user.go_online(uid);
socket.join('uid_' + uid);
// }
/*process.on('uncaughtException', function(err) {
// handle the error safely
@ -70,12 +72,14 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }),
socket.emit('event:connect', {status: 1});
socket.on('disconnect', function() {
// if (uid > 0) {
user.go_offline(uid);
delete users[hs.sessionID];
var index = userSockets[uid].indexOf(socket);
if(index !== -1) {
userSockets[uid].splice(index, 1);
}
// }
});
socket.on('api:get_all_rooms', function(data) {

Loading…
Cancel
Save