Hello,

Thank you for this great module.
Do you know how to use Node.js in multi-site?

Thank you in advance

Comments

markwk’s picture

What do you mean? What's the use case?

danielm’s picture

Hello,

I'd like to use the architecture nodejs with multi-site drupal as below:

/drupal/sites/all/modules/nodejs

/drupal/sites/example1.com
/drupal/sites/example2.com
/drupal/sites/example3.com

example1.com has a single access to its data.
example2.com has a single access to its data.
example3.com has a single access to its data.
example2.com and example3.com have no access to example1.com data and vice-versa

Thank you to have a look at this : http://drupal.org/node/53705

Thank you in advance for your help.

markwk’s picture

Got it! It shouldn't really be an issue in terms of sharing the module code. This is generally how multisite setups work. I run about 20 sites / domains from the same code base.

Not sure I quite follow where/how this differs from how multisite is done already with Drupal? Node.js authentifications and data stuff is being run through Drupal so there shouldn't be any issue about crossing the streams...

danielm’s picture

Hello,
I'm not sure how to configure nodejs.config.js for multi-site Drupal.

For example in the configuration "backend":
Site example1.com: in section "host" must have www.example1.com
Site example2.com: in section "host" must have www.example2.com
But I have only one section "host" in "backend" for nodejs.config.js.
Should I put in the "host" example1.com and example2.com ?

Thank you

markwk’s picture

Good point! Probably going to be a bit more complicated than I thought. Tis an issue...for the issue queue...

danielm’s picture

Maybe use something like this:

$ _SERVER ['HTTP_HOST']

See http://api.drupal.org/api/drupal/includes--bootstrap.inc/function/drupal...

danielm’s picture

See also maybe a parser for HTTP messages. It parses both requests and responses.
https://github.com/joyent/http-parser

tizzo’s picture

I don't think we want to add multisite tracking to node.js. Server.js is very lightweight and I'm not sure there's a compelling reason not to simply run multiple server instances on different ports. Can anyone think of a reason not to run multiple server.js instances?

markwk’s picture

@tizzo: I totally agree about just running multiple instances of server.js for each site. Node.js is extremely light so multiple sites with multiple server.js running shouldn't be an issue.

danielm’s picture

This solution does not meet the standard installation multi-site drupal.

danielm’s picture

The module must be installed only in /sites/all/modules/nodejs for all sites.
Thank you to have a look at this : http://drupal.org/node/53705

Anonymous’s picture

Status: Active » Closed (won't fix)

yep, going to wont-fix this.

server.js is not going to be made multi-site aware.

markwk’s picture

Status: Closed (won't fix) » Active

@danielm: that's true about the module itself as an integration from Drupal to node.js. It can go in the sites/all/modules/ directory.

But the node.js server only really uses server.js and node.config.js files, so essentially you could just take those files, put them anywhere and create different config and launch the node.js server for each site: site1-nodejs/ site2-nodejs/ etc. You can configure each node.js server with each Drupal site.

Anonymous’s picture

Status: Active » Closed (won't fix)
danielm’s picture

Hello,
@beejeebus: Thanks for your reply, I see problems.
@markwk: Thanks for your reply. Below the problems encountered with multiple instances of server.js for each site, even with dedicated ip for more simplicity.

/drupal/sites/example1.com/modules/nodejs (dedicated instance nodejs server example1.com and dedicated ip)
/drupal/sites/example2.com/modules/nodejs (dedicated instance nodejs server example2.com and dedicated ip)
/drupal/sites/example3.com/modules/nodejs (dedicated instance nodejs server example3.com and dedicated ip)

start dedicated instance nodejs server example1.com:
example1.com (dedicated IP): 8080
0.0.0.0:843

start dedicated instance nodejs server example2.com
example2.com (dedicated IP): 8080
port 843 not available

start dedicated instance nodejs server example3.com
example3.com (dedicated IP): 8080
port 843 not available

Listen Address 843 is not available for all instances.

I can do without the standart multi-site drupal, but I really need to have multiple drupal sites on the same server.

markwk’s picture

Use a different port for each node.js server.

danielm’s picture

@markwk: Thank you, it works.

daniorama’s picture

Status: Closed (won't fix) » Active

Hello,

Would it be possible to give a little more information about this issue? For example the nodejs.config.js of one of the sites and the steps to make it work?

Right now the solution is to have a different instance of the nodejs module in every site. I followed the steps in the README but I'm not sure if I have to use "npm install" on every site or just one. I just did it on a test in /all/modules/ and then when I followed the last step of the README I got an error to start the server:

# node server.js
Started http server.
info - socket.io started
warn - error raised: Error: getaddrinfo ENOENT

I'm using 7.x-1.0-rc1 version. Thank you very much.

SocialNicheGuru’s picture

@danielm and all,

I tried to add $ _SERVER ['HTTP_HOST'] on the node js config page

I get the following but will it be replaced by the approrpriate values?

"host":"$ _SERVER [\u0026#039;HTTP_HOST\u0026#039;]",

danielm’s picture

Hi,
See what results from my old test:
@SocialNicheGuru
the $ _SERVER ['HTTP_HOST'] will not work with module nodejs.
@daniorama
See comment #15 and #16 in this post that had worked for me.

SocialNicheGuru’s picture

additional resource for multisite setup with nodejs
http://drupal.arxic.com/node/30

SocialNicheGuru’s picture

I don't quite understand

can nodejs only go into sites/all/modules as said in 13
and I need to copy and configure node.config.js and server.js for each site: site1 and site2 and site3.

is that correct?

MiroslavBanov’s picture

@SocialNicheGuru#22
Copy server.js, nodejs.config.js, package.json. Unless server.js is somehow multisite-aware, but I'm 99% sure it is not. I like to keep my nodejs installations separate from drupal modules, even on single-site drupal installation. Similar question here: http://drupal.org/node/1570326

SocialNicheGuru’s picture

So which is the proper solution:

Option 1:
1. Do not place nodejs in "sites/all/modules/nodejs"
2. place nodejs in "sites/mysitename/modules/nodejs"
3. make the necessary changes to the config.js file just for this sever
3. at prompt type "node server.js" from this directory

Option 2:
1. Place nodejs in sites/all/modules/nodejs
2. place server.js, nodejs.config.js, package.json in a directory in the multisite directory. Should I place it in "sites/mysitename/nodejs1"
3. make the necessary changes to the config.js file just for this sever
3. at prompt type "node server.js" from "sites/mysitename/nodejs1'

MiroslavBanov’s picture

#24
Out of those two I like Option 2 better. The second option keeps your nodejs contributed module clean and in one place, so easier update. You can probably do some symbolic link magic to share files like server.js, package.json

Personally I wouldn't place nodejs server setup in the sites directory at all, but if it makes things manageable for you, I guess it's OK. These are the options I like:

Option 3:
myproject/www <- this is the path to the Drupal installation
myproject/nodejs/example1.com <- specific nodejs server setup

Option 4:
myproject/www/nodejs/example1.com

In case of Option 4 nodejs.config.js is accessible so people can see your serviceKey, but I can deny access to the myproject/www/nodejs folder with a single .htaccess file in it, while in your Option 1 and 2, it's a little bit more complicated.

SocialNicheGuru’s picture

Version: 6.x-1.x-dev » 7.x-1.0-rc1

@MiroslavBanov, If I want to start nodejs at server start up, would your option 3 be easiest?

Any pointers on how to startup nodejs at server startup for each of the multisites?

mobonobomo’s picture

@SocialNicheGuru, re: #22, no, that's not correct that the nodejs module folder can go only in sites/all/modules for a multi-site install. If you look carefully at http://drupal.org/node/53705, each sites/example.com folder can contain 'modules' and 'themes' folders, in addition to the files folder. This is standard, because sometimes in a multi-site install, you might want a module or theme available to only one site.

Domain specific modules and themes should also be placed in /sites/example.com/modules and /sites/example.com/themes respectively.

Basically, copy the entire nodejs module folder into each sites/example.com folder, as I did in my tutorial (thanks for posting the link by the way).

mobonobomo’s picture

@daniorama, re: #18, yes, you have to run npm install in each sites/example.com/modules/nodejs folder.

danielm’s picture

Hi all,
I installed a nodejs multi site again.

That's how I do:

nothing in sites/all/modules


sites/mysite1/modules/nodejs
sites/mysite2/modules/nodejs
sites/mysite3/modules/nodejs
sites/mysite4/modules/nodejs

2° npm install in each site nodejs folder

3° configure nodejs.config.js in each site nodejs folder

4° run nodejs server in each site nodejs folder
/etc/init.d/nodejs1 sites/mysite1/modules/nodejs/server.js
/etc/init.d/nodejs2 sites/mysite2/modules/nodejs/server.js
/etc/init.d/nodejs3 sites/mysite3/modules/nodejs/server.js
/etc/init.d/nodejs4 sites/mysite4/modules/nodejs/server.js

SMTF’s picture

Could someone talk to what it would take to make Drupal NodeJS integration multisite aware?

I understand the desire to keep the project lean and clean; however, I have a need to utilize NodeJS in a production environment with several server clusters operating hundreds of Drupal sites. Running a single nodejs instance for each site is not necessarily the most attractive option.

Thanks in advance.

SocialNicheGuru’s picture

#15 anyway that you could share your nodejs.config.js file?

I am installing in localhost but I have given it a name and the hostname can be identified from my network
hostname: mydev.dev.mydev.com

I am using aegir to deploy my sites

I am having a great deal of trouble configuring this.
1. I am using the standard multisite approach
sites/all/example1.dev.mydev.com
sites/all/example2.dev.mydev.com

2. npm server.js starts fine

3. i get the error: mydev.dev.mydev.com:8282/socket.io/socket.io.js is not found

I am not sure how to arrange the nodejs.config.js file:

settings = {
    host: 'mydev.dev.mydev.com',
    port: 8282,
    serviceKey: '',
    backend: {
        port: 80,
        host: 'example1.dev.socialnicheguru.com',
        scheme: 'http',
        basePath: '',
        messagePath: '/nodejs/message'
    },
    debug: true
};

Edit:
On my local, development system it connect just fine.
socket.io/socket.io.js shows up fine

But when I connect to my site via the web at example.mydev.com it does not work.

I can get to mydev.dev.mydev.com just fine
but I can't get to mydev.dev.mydev.com:8282 any ideas?

mducharme’s picture

I'd like to try to get some feedback at a higher level since this scenario must have been encountered before.

http://drupal.org/node/32178#comment-6990484

If anyone knows a better place/person to bring this up with, let me know.

wiherek’s picture

#31

1. I am using the standard multisite approach
sites/all/example1.dev.mydev.com
sites/all/example2.dev.mydev.com

Do you mean sites/example1.dev.mydev.com? sites/all/SUBSITE is not standard, skip the /all

I can get to mydev.dev.mydev.com just fine
but I can't get to mydev.dev.mydev.com:8282 any ideas?

do you run any part of the setup through https? is your 8282 port open?

you need the port open on both your local machine and the remote nodejs server mydev.dev.mydev.com

aruhdom’s picture

Issue summary: View changes

Hi,

I have got 40 multisite. Is there no way of generalisation of nodejs configuration.

Anonymous’s picture

Version: 7.x-1.0-rc1 » 8.x-1.x-dev

patches to add some support on the drupal side welcome.

if anyone wants to add the feature on the node.js side, please send pull requests to:

https://github.com/beejeebus/drupal-nodejs