Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello,
Thank you for this great module.
Do you know how to use Node.js in multi-site?
Thank you in advance
Comments
Comment #1
markwk CreditAttribution: markwk commentedWhat do you mean? What's the use case?
Comment #2
danielm CreditAttribution: danielm commentedHello,
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.
Comment #3
markwk CreditAttribution: markwk commentedGot 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...
Comment #4
danielm CreditAttribution: danielm commentedHello,
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
Comment #5
markwk CreditAttribution: markwk commentedGood point! Probably going to be a bit more complicated than I thought. Tis an issue...for the issue queue...
Comment #6
danielm CreditAttribution: danielm commentedMaybe use something like this:
$ _SERVER ['HTTP_HOST']
See http://api.drupal.org/api/drupal/includes--bootstrap.inc/function/drupal...
Comment #7
danielm CreditAttribution: danielm commentedSee also maybe a parser for HTTP messages. It parses both requests and responses.
https://github.com/joyent/http-parser
Comment #8
tizzo CreditAttribution: tizzo commentedI 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?
Comment #9
markwk CreditAttribution: markwk commented@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.
Comment #10
danielm CreditAttribution: danielm commentedThis solution does not meet the standard installation multi-site drupal.
Comment #11
danielm CreditAttribution: danielm commentedThe 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
Comment #12
Anonymous (not verified) CreditAttribution: Anonymous commentedyep, going to wont-fix this.
server.js is not going to be made multi-site aware.
Comment #13
markwk CreditAttribution: markwk commented@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.
Comment #14
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #15
danielm CreditAttribution: danielm commentedHello,
@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.
Comment #16
markwk CreditAttribution: markwk commentedUse a different port for each node.js server.
Comment #17
danielm CreditAttribution: danielm commented@markwk: Thank you, it works.
Comment #18
daniorama CreditAttribution: daniorama commentedHello,
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.
Comment #19
SocialNicheGuru CreditAttribution: SocialNicheGuru commented@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;]",
Comment #20
danielm CreditAttribution: danielm commentedHi,
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.
Comment #21
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedadditional resource for multisite setup with nodejs
http://drupal.arxic.com/node/30
Comment #22
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedI 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?
Comment #23
MiroslavBanov CreditAttribution: MiroslavBanov commented@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
Comment #24
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedSo 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'
Comment #25
MiroslavBanov CreditAttribution: MiroslavBanov commented#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.
Comment #26
SocialNicheGuru CreditAttribution: SocialNicheGuru commented@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?
Comment #27
mobonobomo CreditAttribution: mobonobomo commented@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.
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).
Comment #28
mobonobomo CreditAttribution: mobonobomo commented@daniorama, re: #18, yes, you have to run npm install in each sites/example.com/modules/nodejs folder.
Comment #29
danielm CreditAttribution: danielm commentedHi all,
I installed a nodejs multi site again.
That's how I do:
nothing in sites/all/modules
1°
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
Comment #30
SMTF CreditAttribution: SMTF commentedCould 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.
Comment #31
SocialNicheGuru CreditAttribution: SocialNicheGuru commented#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:
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?
Comment #32
mducharme CreditAttribution: mducharme commentedI'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.
Comment #33
wiherek CreditAttribution: wiherek commented#31
Do you mean sites/example1.dev.mydev.com? sites/all/SUBSITE is not standard, skip the /all
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
Comment #34
aruhdom CreditAttribution: aruhdom commentedHi,
I have got 40 multisite. Is there no way of generalisation of nodejs configuration.
Comment #35
Anonymous (not verified) CreditAttribution: Anonymous commentedpatches 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