Discussed this at drupalcon London, we might want to pull the node.js server/config/etc. out into a separate module to be registered on npm. This will a) encourage drupal installs to run the node.js server somewhere outside the drupal doc root, b) encourage other frameworks to utilize its magic.

CommentFileSizeAuthor
#19 1261066-remove_nodejs-19.patch52.22 KBglekli

Comments

Anonymous’s picture

yes, thanks for posting this!

markwk’s picture

This seems like a nice approach.

I'm having some trouble running node.js integration module with drupal 7 via no.de from joyent, it seems like I'll need:

  1. server.js
  2. package.json
  3. nodejs.config.js.example => configured to nodejs.config.js

Anything else?

rogical’s picture

codes/files for nodejs server should be in an standalone directory, less confusing.

  • Commit 44214d2 on drupalconlondon, auth-refactor, 8.x-1.x, 8.x-1.x-head by jzacsh:
    ignoring node_modules, until issue #1261066 on d.o is fixed.
    
    
denes.szabo’s picture

Issue summary: View changes

First I installed the nodejs modules with the npm install as the readme said. It brokes the site if you are using the features module. (I debugged there is a .info file in the node_modules directory. The Drupal regards it as a module's info file. Something happens, but php dies with segfault.)

So I installed the node_modules into the sites/all/libraries/nodejs directory. First I copied the package.json there, then I run the npm install in this dir.

This is my chatroom starting script:

#!/bin/sh
cd $(dirname $0)/../../..
drupal_root=`pwd`
export NODE_PATH=${drupal_root}/sites/all/libraries/nodejs/node_modules
cd ${drupal_root}/sites/all/modules/contrib/nodejs
node server.js

This script is in the profiles/myprofile/bin (the cd step back three levels). The important thing is setup the NODE_PATH env variable.

juliakoelsch’s picture

I just spent time troubleshooting a segfault error occurring when trying to use Features, and I eventually landed here.

The .info files in the node_modules directory are definitely the issue. Drupal gets confused because its expecting .info files to describe a module. There's an issue here to hopefully fix this in core: https://www.drupal.org/node/2329453

The workaround in that thread is to delete the .info files in the node_module directory. Doing this fixed the problem for me. Just wanted to share in case it helps someone else with the same issue.

Anonymous’s picture

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

reviving this.

https://github.com/search?utf8=%E2%9C%93&q=drupal+nodejs

suggestions for names most welcome, else i'm going to create something like 'drupal-nodejs' because i hate names.

glekli’s picture

My vote would be for something that contains the full module name, like "Node.js Integration for Drupal"

glekli’s picture

I have taken the first crack at dividing server.js into submodules (re: #2634908: Organize node.js server into submodules). You can see my progress here:
https://github.com/glekli/drupal-nodejs
Please let me know if the direction I'm headed looks ok, and, if so, I'll issue a pull request into your repo when you have it set up.

Anonymous’s picture

awesome!

please go ahead and add a PR to https://github.com/beejeebus/drupal-nodejs

at this point, i'd err on the side of just getting the code reorganisation done, and getting npm install working.

once that's in and works, we can refactor with less fear.

glekli’s picture

I have put in a pull request: https://github.com/beejeebus/drupal-nodejs/pull/1

By "just getting the code reorganisation done", do you mean just moving server.js to an npm module without any changes?

Anonymous’s picture

thanks for the PR, merged, looks great.

re. refactoring - it's just an order of operations thing. with your initial reorg in now, i'd prefer we focus on shipping the D8 module code and getting the node.js stuff registered on npmjs.com.

after that, i'm happy to continue refactoring/enhancing the code on github and d.o. and releasing new versions.

  • beejeebus committed 87f023d on 8.x-1.x
    #1261066: remove Node.js server code, it now lives at https://github.com...
Anonymous’s picture

ok, i think we can close this now.

Gergely's awesome refactor is in, and the npmjs.com stuff is sorted out. for docs for the new way, i've created #2639020: provide good documentation for setting up the module from npm

Anonymous’s picture

Status: Active » Fixed
glekli’s picture

Status: Fixed » Active

Let me reopen this for one more task to discuss: shall we remove the nodejs app from 7.x as well?
I think, for maintainability, it would be better if there was only one nodejs app to keep up to date. Another benefit is that there would be no need to create a new release for the drupal module if there is an update that only apples to the nodejs app.

Anonymous’s picture

I agree re. D7 and the same code base.

The only thing we have to consider is the transition.

What steps will D7 sites that are upgrading have to take?

Also, the node.js refactor itself, I'd like to see more reports that people are using it, and or a test suite for it before we tell existing sites to make this change.

glekli’s picture

In a nutshell, the two steps needed to switch a D7 site would be applying the module update and installing the nodejs app from NPM or GitHub. After that, the process should be the same as before.

Here are some possible concerns that come to mind:

- The same release that removes the nodejs app from 7.x will also need to include any changes that may be needed to remain compatible with the new server app.
- The configuration file remains compatible, so no changes should be needed there.
- The extension api is mostly backwards compatible, but there is some change in the 'setup' hook. That means extensions may break after the update. As far as I can judge Chat Room andDrupalChat are the two most prevalent modules that depend on Nodejs. Chat Room does not have an extension. DrupalChat does have one. It would be best to coordinate with that module's developers.

Are there any other concerns?
Does anyone know of other modules that depend on NodeJs Integration and have their own nodejs extension?

glekli’s picture

Version: 8.x-1.x-dev » 7.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new52.22 KB

I'm attaching a patch that removes the nodejs app from 7.x and applies all enhancements we have made since pulling out the nodejs app. (In particular, https://github.com/beejeebus/drupal-nodejs/issues/2 and https://github.com/beejeebus/drupal-nodejs/issues/7)

Anonymous’s picture

this looks fine to me, go ahead and push it. please don't roll a release from it yet.

  • Gergely Lekli committed b923354 on 7.x-1.x
    Issue #1261066: Remove node.js code. Make compatibility
    
glekli’s picture

Status: Needs review » Fixed

Great, thanks. Committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.