Community Documentation

Rapid deploy of chatroom 7.x-2.x on mac os X.

Last updated January 26, 2013. Created by danielson317 on January 26, 2013.
Log in to edit this page.

Between nodejs and chatroom it took me 3hrs to figure out how to get this running on a mac. So here is my quick and dirty guide to a rapid deploy on the mac os. The rules probably work for linux and windows if you find another way to install nodejs. And I don't think you can sudo on windows but I'm not sure what the equivalent operation is.

1. Install nodejs drupal module

2. Install nodejs server "brew install nodejs"

3. Navigate to the nodejs drupal module in a terminal "/site/all/modules/contrib/nodejs"

4. Type "npm install". Brew automatically installs npm with nodejs. The command will read a file in the nodejs module and install the correct nodejs addons.

5. Create a file in your nodejs drupal module directory called "nodejs.config.js"

6. The file should look like this:

settings = {
  "scheme":"http",
  "host":"localhost",
  "port":5000,
  "resource":"/socket.io",
  "serviceKey":"key",
  "backend":{
    "port":80,
    "host":"localsite.local",
    "scheme":"http",
    "messagePath":"/nodejs/message"
  },
  "debug":true,
};

The first scheme, host, and port should point to your actually nodejs server. Just choose a port that isn't used. 5000 worked for me.
The backend settings should point to your site. If you don't run virtual host on your system this will need to look a little different.
If the url to your site looks like: http://localsite.local this is the correct configuraiton.
If the url to your site looks like: http://localhost:1028/localsite the settings will look like:
backend: {
    port: 1028,
    host: 'localhost',
    scheme: 'http',
    basePath: '/localsite',
    messagePath: '/nodejs/message'
},

7. Start the server as the sudo user. While in the nodejs drupal module directory still type "sudo node server.js"
8. Add the "serviceKey" value into your settings.php file. This is essential. Leaving this blank will not work. You must set a value in both the settings.php file and in the nodejs.config.js file.
At the bottom of your settings.php file paste: "$conf['nodejs_service_key'] = 'key';"
9. configure the drupal settings to phone out to the nodejs server. Enable the module if you havn't already then visit: "localsite.local/admin/config/nodejs/config"
Make the values look like:
Protocal: http
Host: localhost
server port: 5000
pages: *
And save your changes
10. Create a new node type called "Chat Room" and select "Save and Add Fields"
11. Under Add new field name the field "Chat room" and select the "chatroom" field type and click save. Save a couple more times until you see the field page again.
12. Now add a new Chat Room node: /node/add/chat-room
13. give it a generic title like "test chat room" and save it.
14. Voilla. If you followed all these steps your chat room will be working. Enter text int he lower box and press enter and it will appear above. Open the same page in a different browser (so you have one session in firefox and one session in chrome for example) and log in as a different user. You can chat with yourself for a bit to test it out.

Troubleshooting
1. If you press enter and the text does not disappear from the lower box you do not have nodejs enabled on that page. Visit direction 9 and double check your configuration.
2. If you press enter and the text disappears but does not show up in the upper text box your nodejs configuration file does not match your drupal settings. Double check these directions from the top. Make sure the key is the same in settings.php and nodejs.config.js and settings.php. Make sure you are running server.js as the sudo user. Make sure the backend: points to your local Drupal install.

Comments

You'll also need to run curl

You'll also need to run curl https://npmjs.org/install.sh | sh to install NPM otherwise you won't get past step 4.

......................................................................................................
Hi, my name is Marton Bodonyi and I'm an Interactive Junky.
http://www.interactivejunky.com
.........................................................

Brew installs npm automatically.

Brew automatically installs npm with nodejs. So if you install nodejs with brew you don't need to curl down npm.

Page status

About this page

Drupal version
Drupal 7.x
Audience
Programmers, Site builders
Level
Intermediate
Keywords
install

Site Building Guide

Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.
nobody click here