Skip to content
Browse files

update docs, config, and db for accuracy and simplified deployment

  • Loading branch information...
1 parent dab7d8e commit 4e0c3682d506cf24fd97307282631a84d9d7e10e @lloyd committed Jan 23, 2012
Showing with 35 additions and 53 deletions.
  1. +26 −43 README.md
  2. +3 −3 lib/config.js
  3. +6 −7 lib/db.js
View
69 README.md
@@ -3,63 +3,46 @@ servers and rooms you specify in a config file, and a RESTful JSON API
that you may use to extract and search logs. Also bundled is a sample
client website that can render logs.
-The whole damn thing is self contained (sqlite), runs in a single process,
-and is built with node.js.
-
## Software Prerequisites
- * node.js (0.4.7 is the hotness)
- * connect (>= 1.4.0) `npm install connect`
- * irc (>= 0.2.0) `npm install irc`
- * sqlite (>= 1.0.3) `npm install sqlite`
+ * node.js (0.6.x)
+ * deps listed in `package.json`
+ * a mysql database to connect to
## Testing & Development
+### The web server
+
I hope you'll find ircloggr simple to hack on. Here are the steps to get
a local instance up and running:
- 1. Install node.js and prerequisites listed above
- 2. Copy `config.json.sample` to `config.json` and modify to taste
- 3. start the ircloggr server: `node server/run.js`
- 4. start the test harness: `node test/test_server.js
- 5. point your browser at http://localhost:60000/
+ 1. Install node.js
+ 2. git clone this repository
+ 3. npm install
+ 4. install mysql, create an `ircloggr` database, grant all privs to `ircloggr` user
+ 5. PORT=8080 npm start
-The "test server" in step four is basically a tiny little web server
-that serves up the files in /static at root, and proxies requests to
-/api/* to the ircloggr [web services api](/lloyd/ircloggr/blob/master/WSAPI.md). It
-simulates the role that nginx or another webserver/reverse proxy
-server might play during deployment.
+Visit `http://127.0.0.1:8080/` in your browser
-## Deployment
+### The logger daemon
-One way to deploy the server is behind an nginx reverse proxy.
-nginx can handle response compression, and caching (TODO). Here's
-a sample nginx configuration
+ 1. SERVERS=irc.freenode.net=ircloggr_test
- http {
- include mime.types;
+Now log into `irc.freenode.net` #ircloggr_test and notice that your utterances are
+visible through the web view.
- gzip on;
- gzip_proxied any;
- gzip_types text/html application/json application/x-javascript text/css;
-
- server {
- listen 80;
- server_name irclog.gr;
+## Deployment
- location / {
- root /home/http/ircloggr/static;
- index index.html;
- }
+Now that you've got it running, deployment on any provider should be pretty
+straightforward. Here are steps to get up and running on heroku:
- location = /api/code_update {
- internal;
- }
+ * heroku create --stack cedar --buildpack http://github.com/hakobera/heroku-buildpack-nodejs.git // create a new app on heroku using node 0.6+
+ * heroku addons:add cleardb:ignite // add a mysql database
+ * heroku config:add IP_ADDRESS=0.0.0.0
+ * heroku config:add BOT_NAME=my_ircloggr_bot
+ * git push heroku master
- location /api/ {
- proxy_pass http://127.0.0.1:51432/;
- proxy_set_header X-Real-IP $remote_addr;
- }
- }
- }
+you should be running! now let's configure a room and the daemon
+ * heroku config:add SERVERS=irc.freenode.net=ircloggr_testroom
+ $ heroku scale web=1 worker=1
View
6 lib/config.js
@@ -23,7 +23,8 @@ exports.db_user = 'ircloggr';
exports.db_pass = undefined;
exports.database = 'ircloggr';
-// handle database string set in the environment
+// handle database string set in the environment
+process.env['MYSQL_URL'] = process.env['MYSQL_URL'] || process.env['CLEARDB_DATABASE_URL_A'];
if (process.env['MYSQL_URL']) {
var u = url.parse(process.env['MYSQL_URL']);
exports.db_host = u.host;
@@ -58,7 +59,7 @@ exports.import_config = function() {
else {
try {
var conf = JSON.parse(fs.readFileSync(exports.config_path));
-
+
for (var k in conf) {
if (exports[k] === undefined || k.substr(0,5) === "parse")
throw "unsupported key: " + k;
@@ -72,7 +73,6 @@ exports.import_config = function() {
}
}
-
winston.info('configured rooms:');
winston.info(JSON.stringify(exports.servers, null, 4));
};
View
13 lib/db.js
@@ -15,15 +15,15 @@ var client;
function toDBName(host, room) {
if (!host || !room) throw 'missing required args';
if (room.substr(0,1) === "#") room = room.substr(1);
- host = host.replace('-', '_');
+ room = room.replace('-', '___');
return (host.replace(/\./g, '$') + "$$" + room);
}
function fromDBName(dbName) {
var ar = dbName.split('$$');
return {
- host: ar[0].replace('_', '-')replace(/\$/g, '.'),
- room: ar[1]
+ host: ar[0].replace(/\$/g, '.'),
+ room: ar[1].replace('___', '-')
};
}
@@ -116,7 +116,7 @@ exports.listRooms = function(cb) {
// prevent simul requests from causing expensive queries to run in ||
if (listRoomsCache) listRoomsCacheUpdated = new Date();
-
+
client.query("SHOW TABLES", function(err, tables) {
if (err) return cb ? cb(err) : undefined;
var rooms = [ ];
@@ -197,14 +197,13 @@ exports.clearTestTables = function(cb) {
exports.addRoom = function(host, room, cb) {
var dbName = toDBName(host, room);
- // XXX: fulltext indexing!
var sql = "CREATE TABLE IF NOT EXISTS " + dbName + " (" +
- "id BIGINT AUTO_INCREMENT PRIMARY KEY," +
+ "id BIGINT AUTO_INCREMENT PRIMARY KEY," +
"ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL," +
"who CHAR(48) NOT NULL," +
"msg TEXT," +
"FULLTEXT (who,msg)," +
- "INDEX(ts)" +
+ "INDEX(ts)" +
") ENGINE=MyISAM;";
client.query('set @@auto_increment_increment=1', function(err) {
if (err) return cb(err);

0 comments on commit 4e0c368

Please sign in to comment.
Something went wrong with that request. Please try again.