mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-11 01:31:29 -04:00
remove trailing whitespace
This commit is contained in:
parent
e1edc8079f
commit
0b6709392b
104 changed files with 1479 additions and 1479 deletions
|
@ -11,26 +11,26 @@ if [ -d "../bin" ]; then
|
|||
fi
|
||||
|
||||
#Is wget installed?
|
||||
hash wget > /dev/null 2>&1 || {
|
||||
hash wget > /dev/null 2>&1 || {
|
||||
echo "Please install wget" >&2
|
||||
exit 1
|
||||
exit 1
|
||||
}
|
||||
|
||||
#Is zip installed?
|
||||
hash zip > /dev/null 2>&1 || {
|
||||
hash zip > /dev/null 2>&1 || {
|
||||
echo "Please install zip" >&2
|
||||
exit 1
|
||||
exit 1
|
||||
}
|
||||
|
||||
#Is zip installed?
|
||||
hash unzip > /dev/null 2>&1 || {
|
||||
hash unzip > /dev/null 2>&1 || {
|
||||
echo "Please install unzip" >&2
|
||||
exit 1
|
||||
exit 1
|
||||
}
|
||||
|
||||
START_FOLDER=$(pwd);
|
||||
|
||||
echo "create a clean environment in /tmp/etherpad-lite-win..."
|
||||
echo "create a clean environment in /tmp/etherpad-lite-win..."
|
||||
rm -rf /tmp/etherpad-lite-win
|
||||
cp -ar . /tmp/etherpad-lite-win
|
||||
cd /tmp/etherpad-lite-win
|
||||
|
|
|
@ -25,11 +25,11 @@ async.series([
|
|||
{
|
||||
db.init(callback);
|
||||
},
|
||||
//get the pad
|
||||
//get the pad
|
||||
function (callback)
|
||||
{
|
||||
padManager = require('../src/node/db/PadManager');
|
||||
|
||||
|
||||
padManager.doesPadExists(padId, function(err, exists)
|
||||
{
|
||||
if(!exists)
|
||||
|
@ -37,8 +37,8 @@ async.series([
|
|||
console.error("Pad does not exist");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
padManager.getPad(padId, function(err, _pad)
|
||||
|
||||
padManager.getPad(padId, function(err, _pad)
|
||||
{
|
||||
pad = _pad;
|
||||
callback(err);
|
||||
|
@ -46,7 +46,7 @@ async.series([
|
|||
});
|
||||
},
|
||||
function (callback)
|
||||
{
|
||||
{
|
||||
//create an array with key kevisions
|
||||
//key revisions always save the full pad atext
|
||||
var head = pad.getHeadRevisionNumber();
|
||||
|
@ -55,7 +55,7 @@ async.series([
|
|||
{
|
||||
keyRevisions.push(i);
|
||||
}
|
||||
|
||||
|
||||
//run trough all key revisions
|
||||
async.forEachSeries(keyRevisions, function(keyRev, callback)
|
||||
{
|
||||
|
@ -65,10 +65,10 @@ async.series([
|
|||
{
|
||||
revisionsNeeded.push(i);
|
||||
}
|
||||
|
||||
|
||||
//this array will hold all revision changesets
|
||||
var revisions = [];
|
||||
|
||||
|
||||
//run trough all needed revisions and get them from the database
|
||||
async.forEach(revisionsNeeded, function(revNum, callback)
|
||||
{
|
||||
|
@ -84,14 +84,14 @@ async.series([
|
|||
callback(err);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//check if the pad has a pool
|
||||
if(pad.pool === undefined )
|
||||
{
|
||||
console.error("Attribute pool is missing");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
|
||||
//check if there is a atext in the keyRevisions
|
||||
if(revisions[keyRev] === undefined || revisions[keyRev].meta === undefined || revisions[keyRev].meta.atext === undefined)
|
||||
{
|
||||
|
@ -99,10 +99,10 @@ async.series([
|
|||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var apool = pad.pool;
|
||||
var atext = revisions[keyRev].meta.atext;
|
||||
|
||||
|
||||
for(var i=keyRev+1;i<=keyRev+100 && i<=head; i++)
|
||||
{
|
||||
try
|
||||
|
@ -118,7 +118,7 @@ async.series([
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
callback();
|
||||
});
|
||||
}, callback);
|
||||
|
@ -126,8 +126,8 @@ async.series([
|
|||
], function (err)
|
||||
{
|
||||
if(err) throw err;
|
||||
else
|
||||
{
|
||||
else
|
||||
{
|
||||
console.log("finished");
|
||||
process.exit(0);
|
||||
}
|
||||
|
|
146
bin/convert.js
146
bin/convert.js
|
@ -27,21 +27,21 @@ log("open output file...");
|
|||
var sqlOutput = fs.openSync(sqlOutputFile, "w");
|
||||
var sql = "SET CHARACTER SET UTF8;\n" +
|
||||
"CREATE TABLE IF NOT EXISTS `store` ( \n" +
|
||||
"`key` VARCHAR( 100 ) NOT NULL , \n" +
|
||||
"`value` LONGTEXT NOT NULL , \n" +
|
||||
"`key` VARCHAR( 100 ) NOT NULL , \n" +
|
||||
"`value` LONGTEXT NOT NULL , \n" +
|
||||
"PRIMARY KEY ( `key` ) \n" +
|
||||
") ENGINE = INNODB;\n" +
|
||||
") ENGINE = INNODB;\n" +
|
||||
"START TRANSACTION;\n\n";
|
||||
fs.writeSync(sqlOutput, sql);
|
||||
log("done");
|
||||
|
||||
//set setings for ep db
|
||||
var etherpadDB= new mysql.Client();
|
||||
etherpadDB.host = settings.etherpadDB.host;
|
||||
etherpadDB.host = settings.etherpadDB.host;
|
||||
etherpadDB.port = settings.etherpadDB.port;
|
||||
etherpadDB.database = settings.etherpadDB.database;
|
||||
etherpadDB.user = settings.etherpadDB.user;
|
||||
etherpadDB.password = settings.etherpadDB.password;
|
||||
etherpadDB.database = settings.etherpadDB.database;
|
||||
etherpadDB.user = settings.etherpadDB.user;
|
||||
etherpadDB.password = settings.etherpadDB.password;
|
||||
|
||||
//get the timestamp once
|
||||
var timestamp = new Date().getTime();
|
||||
|
@ -53,7 +53,7 @@ async.series([
|
|||
function(callback)
|
||||
{
|
||||
log("get all padIds out of the database...");
|
||||
|
||||
|
||||
etherpadDB.query("SELECT ID FROM PAD_META", [], function(err, _padIDs)
|
||||
{
|
||||
padIDs = _padIDs;
|
||||
|
@ -63,9 +63,9 @@ async.series([
|
|||
function(callback)
|
||||
{
|
||||
log("done");
|
||||
|
||||
|
||||
//create a queue with a concurrency 100
|
||||
var queue = async.queue(function (padId, callback)
|
||||
var queue = async.queue(function (padId, callback)
|
||||
{
|
||||
convertPad(padId, function(err)
|
||||
{
|
||||
|
@ -73,10 +73,10 @@ async.series([
|
|||
callback(err);
|
||||
});
|
||||
}, 100);
|
||||
|
||||
|
||||
//set the step callback as the queue callback
|
||||
queue.drain = callback;
|
||||
|
||||
|
||||
//add the padids to the worker queue
|
||||
for(var i=0,length=padIDs.length;i<length;i++)
|
||||
{
|
||||
|
@ -86,25 +86,25 @@ async.series([
|
|||
], function(err)
|
||||
{
|
||||
if(err) throw err;
|
||||
|
||||
|
||||
//write the groups
|
||||
var sql = "";
|
||||
for(var proID in proID2groupID)
|
||||
{
|
||||
var groupID = proID2groupID[proID];
|
||||
var subdomain = proID2subdomain[proID];
|
||||
|
||||
|
||||
sql+="REPLACE INTO store VALUES (" + etherpadDB.escape("group:" + groupID) + ", " + etherpadDB.escape(JSON.stringify(groups[groupID]))+ ");\n";
|
||||
sql+="REPLACE INTO store VALUES (" + etherpadDB.escape("mapper2group:subdomain:" + subdomain) + ", " + etherpadDB.escape(groupID)+ ");\n";
|
||||
}
|
||||
|
||||
|
||||
//close transaction
|
||||
sql+="COMMIT;";
|
||||
|
||||
|
||||
//end the sql file
|
||||
fs.writeSync(sqlOutput, sql, undefined, "utf-8");
|
||||
fs.closeSync(sqlOutput);
|
||||
|
||||
|
||||
log("finished.");
|
||||
process.exit(0);
|
||||
});
|
||||
|
@ -119,7 +119,7 @@ var padsDone = 0;
|
|||
function incrementPadStats()
|
||||
{
|
||||
padsDone++;
|
||||
|
||||
|
||||
if(padsDone%100 == 0)
|
||||
{
|
||||
var averageTime = Math.round(padsDone/((new Date().getTime() - startTime)/1000));
|
||||
|
@ -150,10 +150,10 @@ function convertPad(padId, callback)
|
|||
function(callback)
|
||||
{
|
||||
var sql = "SELECT * FROM `PAD_CHAT_TEXT` WHERE NUMID = (SELECT `NUMID` FROM `PAD_CHAT_META` WHERE ID=?)";
|
||||
|
||||
|
||||
etherpadDB.query(sql, [padId], function(err, results)
|
||||
{
|
||||
if(!err)
|
||||
if(!err)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -164,7 +164,7 @@ function convertPad(padId, callback)
|
|||
}
|
||||
}catch(e) {err = e}
|
||||
}
|
||||
|
||||
|
||||
callback(err);
|
||||
});
|
||||
},
|
||||
|
@ -172,10 +172,10 @@ function convertPad(padId, callback)
|
|||
function(callback)
|
||||
{
|
||||
var sql = "SELECT * FROM `PAD_REVS_TEXT` WHERE NUMID = (SELECT `NUMID` FROM `PAD_REVS_META` WHERE ID=?)";
|
||||
|
||||
|
||||
etherpadDB.query(sql, [padId], function(err, results)
|
||||
{
|
||||
if(!err)
|
||||
if(!err)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -186,7 +186,7 @@ function convertPad(padId, callback)
|
|||
}
|
||||
}catch(e) {err = e}
|
||||
}
|
||||
|
||||
|
||||
callback(err);
|
||||
});
|
||||
},
|
||||
|
@ -194,10 +194,10 @@ function convertPad(padId, callback)
|
|||
function(callback)
|
||||
{
|
||||
var sql = "SELECT * FROM `PAD_REVMETA_TEXT` WHERE NUMID = (SELECT `NUMID` FROM `PAD_REVMETA_META` WHERE ID=?)";
|
||||
|
||||
|
||||
etherpadDB.query(sql, [padId], function(err, results)
|
||||
{
|
||||
if(!err)
|
||||
if(!err)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -208,7 +208,7 @@ function convertPad(padId, callback)
|
|||
}
|
||||
}catch(e) {err = e}
|
||||
}
|
||||
|
||||
|
||||
callback(err);
|
||||
});
|
||||
},
|
||||
|
@ -216,7 +216,7 @@ function convertPad(padId, callback)
|
|||
function(callback)
|
||||
{
|
||||
var sql = "SELECT `JSON` FROM `PAD_APOOL` WHERE `ID` = ?";
|
||||
|
||||
|
||||
etherpadDB.query(sql, [padId], function(err, results)
|
||||
{
|
||||
if(!err)
|
||||
|
@ -226,7 +226,7 @@ function convertPad(padId, callback)
|
|||
apool=JSON.parse(results[0].JSON).x;
|
||||
}catch(e) {err = e}
|
||||
}
|
||||
|
||||
|
||||
callback(err);
|
||||
});
|
||||
},
|
||||
|
@ -234,10 +234,10 @@ function convertPad(padId, callback)
|
|||
function(callback)
|
||||
{
|
||||
var sql = "SELECT * FROM `PAD_AUTHORS_TEXT` WHERE NUMID = (SELECT `NUMID` FROM `PAD_AUTHORS_META` WHERE ID=?)";
|
||||
|
||||
|
||||
etherpadDB.query(sql, [padId], function(err, results)
|
||||
{
|
||||
if(!err)
|
||||
if(!err)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -248,7 +248,7 @@ function convertPad(padId, callback)
|
|||
}
|
||||
}catch(e) {err = e}
|
||||
}
|
||||
|
||||
|
||||
callback(err);
|
||||
});
|
||||
},
|
||||
|
@ -256,17 +256,17 @@ function convertPad(padId, callback)
|
|||
function(callback)
|
||||
{
|
||||
var sql = "SELECT JSON FROM `PAD_META` WHERE ID=?";
|
||||
|
||||
|
||||
etherpadDB.query(sql, [padId], function(err, results)
|
||||
{
|
||||
if(!err)
|
||||
if(!err)
|
||||
{
|
||||
try
|
||||
{
|
||||
padmeta = JSON.parse(results[0].JSON).x;
|
||||
}catch(e) {err = e}
|
||||
}
|
||||
|
||||
|
||||
callback(err);
|
||||
});
|
||||
},
|
||||
|
@ -279,19 +279,19 @@ function convertPad(padId, callback)
|
|||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//get the proID out of this padID
|
||||
var proID = padId.split("$")[0];
|
||||
|
||||
|
||||
var sql = "SELECT subDomain FROM pro_domains WHERE ID = ?";
|
||||
|
||||
|
||||
etherpadDB.query(sql, [proID], function(err, results)
|
||||
{
|
||||
if(!err)
|
||||
{
|
||||
subdomain = results[0].subDomain;
|
||||
}
|
||||
|
||||
|
||||
callback(err);
|
||||
});
|
||||
}
|
||||
|
@ -301,105 +301,105 @@ function convertPad(padId, callback)
|
|||
{
|
||||
//saves all values that should be written to the database
|
||||
var values = {};
|
||||
|
||||
|
||||
//this is a pro pad, let's convert it to a group pad
|
||||
if(padId.indexOf("$") != -1)
|
||||
{
|
||||
var padIdParts = padId.split("$");
|
||||
var proID = padIdParts[0];
|
||||
var padName = padIdParts[1];
|
||||
|
||||
|
||||
var groupID
|
||||
|
||||
|
||||
//this proID is not converted so far, do it
|
||||
if(proID2groupID[proID] == null)
|
||||
{
|
||||
groupID = "g." + randomString(16);
|
||||
|
||||
|
||||
//create the mappers for this new group
|
||||
proID2groupID[proID] = groupID;
|
||||
proID2subdomain[proID] = subdomain;
|
||||
groups[groupID] = {pads: {}};
|
||||
}
|
||||
|
||||
|
||||
//use the generated groupID;
|
||||
groupID = proID2groupID[proID];
|
||||
|
||||
|
||||
//rename the pad
|
||||
padId = groupID + "$" + padName;
|
||||
|
||||
|
||||
//set the value for this pad in the group
|
||||
groups[groupID].pads[padId] = 1;
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
var newAuthorIDs = {};
|
||||
var oldName2newName = {};
|
||||
|
||||
|
||||
//replace the authors with generated authors
|
||||
// we need to do that cause etherpad saves pad local authors, etherpad lite uses them global
|
||||
for(var i in apool.numToAttrib)
|
||||
{
|
||||
var key = apool.numToAttrib[i][0];
|
||||
var value = apool.numToAttrib[i][1];
|
||||
|
||||
|
||||
//skip non authors and anonymous authors
|
||||
if(key != "author" || value == "")
|
||||
continue;
|
||||
|
||||
|
||||
//generate new author values
|
||||
var authorID = "a." + randomString(16);
|
||||
var authorColorID = authors[i].colorId || Math.floor(Math.random()*32);
|
||||
var authorName = authors[i].name || null;
|
||||
|
||||
|
||||
//overwrite the authorID of the attribute pool
|
||||
apool.numToAttrib[i][1] = authorID;
|
||||
|
||||
|
||||
//write the author to the database
|
||||
values["globalAuthor:" + authorID] = {"colorId" : authorColorID, "name": authorName, "timestamp": timestamp};
|
||||
|
||||
|
||||
//save in mappers
|
||||
newAuthorIDs[i] = authorID;
|
||||
oldName2newName[value] = authorID;
|
||||
}
|
||||
|
||||
|
||||
//save all revisions
|
||||
for(var i=0;i<changesets.length;i++)
|
||||
{
|
||||
values["pad:" + padId + ":revs:" + i] = {changeset: changesets[i],
|
||||
values["pad:" + padId + ":revs:" + i] = {changeset: changesets[i],
|
||||
meta : {
|
||||
author: newAuthorIDs[changesetsMeta[i].a],
|
||||
timestamp: changesetsMeta[i].t,
|
||||
atext: changesetsMeta[i].atext || undefined
|
||||
}};
|
||||
}
|
||||
|
||||
|
||||
//save all chat messages
|
||||
for(var i=0;i<chatMessages.length;i++)
|
||||
{
|
||||
values["pad:" + padId + ":chat:" + i] = {"text": chatMessages[i].lineText,
|
||||
"userId": oldName2newName[chatMessages[i].userId],
|
||||
values["pad:" + padId + ":chat:" + i] = {"text": chatMessages[i].lineText,
|
||||
"userId": oldName2newName[chatMessages[i].userId],
|
||||
"time": chatMessages[i].time}
|
||||
}
|
||||
|
||||
|
||||
//generate the latest atext
|
||||
var fullAPool = (new AttributePool()).fromJsonable(apool);
|
||||
var keyRev = Math.floor(padmeta.head / padmeta.keyRevInterval) * padmeta.keyRevInterval;
|
||||
var atext = changesetsMeta[keyRev].atext;
|
||||
var curRev = keyRev;
|
||||
while (curRev < padmeta.head)
|
||||
while (curRev < padmeta.head)
|
||||
{
|
||||
curRev++;
|
||||
var changeset = changesets[curRev];
|
||||
atext = Changeset.applyToAText(changeset, atext, fullAPool);
|
||||
}
|
||||
|
||||
values["pad:" + padId] = {atext: atext,
|
||||
pool: apool,
|
||||
head: padmeta.head,
|
||||
|
||||
values["pad:" + padId] = {atext: atext,
|
||||
pool: apool,
|
||||
head: padmeta.head,
|
||||
chatHead: padmeta.numChatMessages }
|
||||
|
||||
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
|
@ -408,13 +408,13 @@ function convertPad(padId, callback)
|
|||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var sql = "";
|
||||
for(var key in values)
|
||||
{
|
||||
sql+="REPLACE INTO store VALUES (" + etherpadDB.escape(key) + ", " + etherpadDB.escape(JSON.stringify(values[key]))+ ");\n";
|
||||
}
|
||||
|
||||
|
||||
fs.writeSync(sqlOutput, sql, undefined, "utf-8");
|
||||
callback();
|
||||
}
|
||||
|
@ -430,24 +430,24 @@ function parsePage(array, pageStart, offsets, data, json)
|
|||
{
|
||||
var start = 0;
|
||||
var lengths = offsets.split(",");
|
||||
|
||||
|
||||
for(var i=0;i<lengths.length;i++)
|
||||
{
|
||||
var unitLength = lengths[i];
|
||||
|
||||
|
||||
//skip empty units
|
||||
if(unitLength == "")
|
||||
continue;
|
||||
|
||||
|
||||
//parse the number
|
||||
unitLength = Number(unitLength);
|
||||
|
||||
|
||||
//cut the unit out of data
|
||||
var unit = data.substr(start, unitLength);
|
||||
|
||||
|
||||
//put it into the array
|
||||
array[pageStart + i] = json ? JSON.parse(unit) : unit;
|
||||
|
||||
|
||||
//update start
|
||||
start+=unitLength;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"etherpadDB":
|
||||
"etherpadDB":
|
||||
{
|
||||
"host": "localhost",
|
||||
"port": 3306,
|
||||
|
|
|
@ -11,11 +11,11 @@ fi
|
|||
#prepare the enviroment
|
||||
bin/installDeps.sh || exit 1
|
||||
|
||||
hash node-inspector > /dev/null 2>&1 || {
|
||||
hash node-inspector > /dev/null 2>&1 || {
|
||||
echo "You need to install node-inspector to run the tests!" >&2
|
||||
echo "You can install it with npm" >&2
|
||||
echo "Run: npm install -g node-inspector" >&2
|
||||
exit 1
|
||||
exit 1
|
||||
}
|
||||
|
||||
node-inspector &
|
||||
|
@ -24,5 +24,5 @@ echo "If you are new to node-inspector, take a look at this video: http://youtu.
|
|||
|
||||
node --debug node_modules/ep_etherpad-lite/node/server.js $*
|
||||
|
||||
#kill node-inspector before ending
|
||||
#kill node-inspector before ending
|
||||
kill $!
|
||||
|
|
|
@ -16,7 +16,7 @@ log4js.setGlobalLogLevel("INFO");
|
|||
var async = require("async");
|
||||
var db = require('../node/db/DB');
|
||||
var dirty = require("dirty")(padId + ".db");
|
||||
var padManager;
|
||||
var padManager;
|
||||
var pad;
|
||||
var neededDBValues = ["pad:"+padId];
|
||||
|
||||
|
@ -26,12 +26,12 @@ async.series([
|
|||
{
|
||||
db.init(callback);
|
||||
},
|
||||
//get the pad
|
||||
//get the pad
|
||||
function (callback)
|
||||
{
|
||||
padManager = require('../node/db/PadManager');
|
||||
|
||||
padManager.getPad(padId, function(err, _pad)
|
||||
|
||||
padManager.getPad(padId, function(err, _pad)
|
||||
{
|
||||
pad = _pad;
|
||||
callback(err);
|
||||
|
@ -45,21 +45,21 @@ async.series([
|
|||
{
|
||||
neededDBValues.push("globalAuthor:" + authors[i]);
|
||||
}
|
||||
|
||||
|
||||
//add all revisions
|
||||
var revHead = pad.head;
|
||||
for(var i=0;i<=revHead;i++)
|
||||
{
|
||||
neededDBValues.push("pad:"+padId+":revs:" + i);
|
||||
}
|
||||
|
||||
|
||||
//get all chat values
|
||||
var chatHead = pad.chatHead;
|
||||
for(var i=0;i<=chatHead;i++)
|
||||
{
|
||||
neededDBValues.push("pad:"+padId+":chat:" + i);
|
||||
}
|
||||
|
||||
|
||||
//get and set all values
|
||||
async.forEach(neededDBValues, function(dbkey, callback)
|
||||
{
|
||||
|
@ -67,7 +67,7 @@ async.series([
|
|||
{
|
||||
if(err) { callback(err); return}
|
||||
dbvalue=JSON.parse(dbvalue);
|
||||
|
||||
|
||||
dirty.set(dbkey, dbvalue, callback);
|
||||
});
|
||||
}, callback);
|
||||
|
@ -75,8 +75,8 @@ async.series([
|
|||
], function (err)
|
||||
{
|
||||
if(err) throw err;
|
||||
else
|
||||
{
|
||||
else
|
||||
{
|
||||
console.log("finished");
|
||||
process.exit();
|
||||
}
|
||||
|
|
|
@ -10,35 +10,35 @@ fi
|
|||
|
||||
#Is gnu-grep (ggrep) installed on SunOS (Solaris)
|
||||
if [ $(uname) = "SunOS" ]; then
|
||||
hash ggrep > /dev/null 2>&1 || {
|
||||
hash ggrep > /dev/null 2>&1 || {
|
||||
echo "Please install ggrep (pkg install gnu-grep)" >&2
|
||||
exit 1
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
|
||||
#Is wget installed?
|
||||
hash curl > /dev/null 2>&1 || {
|
||||
hash curl > /dev/null 2>&1 || {
|
||||
echo "Please install curl" >&2
|
||||
exit 1
|
||||
exit 1
|
||||
}
|
||||
|
||||
#Is node installed?
|
||||
hash node > /dev/null 2>&1 || {
|
||||
hash node > /dev/null 2>&1 || {
|
||||
echo "Please install node.js ( http://nodejs.org )" >&2
|
||||
exit 1
|
||||
exit 1
|
||||
}
|
||||
|
||||
#Is npm installed?
|
||||
hash npm > /dev/null 2>&1 || {
|
||||
hash npm > /dev/null 2>&1 || {
|
||||
echo "Please install npm ( http://npmjs.org )" >&2
|
||||
exit 1
|
||||
exit 1
|
||||
}
|
||||
|
||||
#check npm version
|
||||
NPM_VERSION=$(npm --version)
|
||||
if [ ! $(echo $NPM_VERSION | cut -d "." -f 1) = "1" ]; then
|
||||
echo "You're running a wrong version of npm, you're using $NPM_VERSION, we need 1.x" >&2
|
||||
exit 1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#check node version
|
||||
|
@ -46,7 +46,7 @@ NODE_VERSION=$(node --version)
|
|||
NODE_V_MINOR=$(echo $NODE_VERSION | cut -d "." -f 1-2)
|
||||
if [ ! $NODE_V_MINOR = "v0.8" ] && [ ! $NODE_V_MINOR = "v0.6" ]; then
|
||||
echo "You're running a wrong version of node, you're using $NODE_VERSION, we need v0.6.x or v0.8.x" >&2
|
||||
exit 1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#Get the name of the settings file
|
||||
|
@ -70,9 +70,9 @@ echo "Ensure that all dependencies are up to date..."
|
|||
[ -e ep_etherpad-lite ] || ln -s ../src ep_etherpad-lite
|
||||
cd ep_etherpad-lite
|
||||
npm install
|
||||
) || {
|
||||
) || {
|
||||
rm -rf node_modules
|
||||
exit 1
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo "Ensure jQuery is downloaded and up to date..."
|
||||
|
@ -105,7 +105,7 @@ do
|
|||
if [ ! -f "src/static/custom/$f.js" ]; then
|
||||
cp "src/static/custom/js.template" "src/static/custom/$f.js" || exit 1
|
||||
fi
|
||||
|
||||
|
||||
if [ ! -f "src/static/custom/$f.css" ]; then
|
||||
cp "src/static/custom/css.template" "src/static/custom/$f.css" || exit 1
|
||||
fi
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
This load tester is extremely useful for testing how many dormant clients can connect to etherpad lite.
|
||||
This load tester is extremely useful for testing how many dormant clients can connect to etherpad lite.
|
||||
|
||||
TODO:
|
||||
Emulate characters being typed into a pad
|
||||
|
@ -14,7 +14,7 @@ Installed Xvfb and PhantomJS
|
|||
I installed Xvfb following (roughly) this guide: http://blog.martin-lyness.com/archives/installing-xvfb-on-ubuntu-9-10-karmic-koala
|
||||
|
||||
#sudo apt-get install xvfb
|
||||
#sudo apt-get install xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic
|
||||
#sudo apt-get install xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic
|
||||
|
||||
Launched two instances of Xvfb directly from the terminal:
|
||||
|
||||
|
@ -58,15 +58,15 @@ And finally a launcher script that uses screen to run 400 instances of PhantomJS
|
|||
|
||||
### BEGIN SHELL SCRIPT ###
|
||||
|
||||
#!/bin/bash
|
||||
#!/bin/bash
|
||||
|
||||
# connect 200 instances to display :0
|
||||
# connect 200 instances to display :0
|
||||
for i in {1..200}
|
||||
do
|
||||
DISPLAY=:0 screen -d -m phantomjs loader.js http://ec2-50-17-168-xx.compute-1.amazonaws.com:9001/p/pad2 && sleep 2
|
||||
done
|
||||
|
||||
# connect 200 instances to display :1
|
||||
# connect 200 instances to display :1
|
||||
for i in {1..200}
|
||||
do
|
||||
DISPLAY=:1 screen -d -m phantomjs loader.js http://ec2-50-17-168-xx.compute-1.amazonaws.com:9001/p/pad2 && sleep 2
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
ERROR_HANDLING=0
|
||||
# Your email address which should recieve the error messages
|
||||
EMAIL_ADDRESS="no-reply@example.com"
|
||||
# Sets the minimun amount of time betweens the sending of error emails.
|
||||
# This ensures you not get spamed while a endless reboot loop
|
||||
# Sets the minimun amount of time betweens the sending of error emails.
|
||||
# This ensures you not get spamed while a endless reboot loop
|
||||
# It's the time in seconds
|
||||
TIME_BETWEEN_EMAILS=600 # 10 minutes
|
||||
|
||||
|
@ -37,7 +37,7 @@ do
|
|||
if [ ! -f $1 ]; then
|
||||
touch $1 || ( echo "Logfile '$1' is not writeable" && exit 1 )
|
||||
fi
|
||||
|
||||
|
||||
#check if the file is writeable
|
||||
if [ ! -w $1 ]; then
|
||||
echo "Logfile '$1' is not writeable"
|
||||
|
@ -46,21 +46,21 @@ do
|
|||
|
||||
#start the application
|
||||
bin/run.sh >>$1 2>>$1
|
||||
|
||||
|
||||
#Send email
|
||||
if [ $ERROR_HANDLING = 1 ]; then
|
||||
TIME_NOW=$(date +%s)
|
||||
TIME_SINCE_LAST_SEND=$(($TIME_NOW - $LAST_EMAIL_SEND))
|
||||
|
||||
|
||||
if [ $TIME_SINCE_LAST_SEND -gt $TIME_BETWEEN_EMAILS ]; then
|
||||
printf "Server was restared at: $(date)\nThe last 50 lines of the log before the error happens:\n $(tail -n 50 $1)" | mail -s "Pad Server was restarted" $EMAIL_ADDRESS
|
||||
|
||||
|
||||
LAST_EMAIL_SEND=$TIME_NOW
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
echo "RESTART!" >>$1
|
||||
|
||||
|
||||
#Sleep 10 seconds before restart
|
||||
sleep 10
|
||||
done
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue