You are not logged in.

#1 2009-12-02 17:49:36

dw0rm
Member
Registered: 2009-12-02
Posts: 8

node.js

Hello, I hope some of you have heard of node.js, which is event based server side javascript.

I wanted to give it a try, but  failed to compile it on Webfaction, ran into problem similar to this post.

I like Webfaction for it customizability, why not to make it possible to run node.js as well?

Offline

 

#2 2009-12-02 18:45:15

seanf
Administrator
Registered: 2008-02-01
Posts: 1899
Website

Re: node.js

You can build node.js on our servers. The trick is to use the 'jobs' flag on the configure step, eg:

Code:

./configure --jobs=1 --prefix=$HOME

Hope that helps!

Offline

 

#3 2009-12-02 23:30:03

dw0rm
Member
Registered: 2009-12-02
Posts: 8

Re: node.js

seanf, thanks that did a trick!

Offline

 

#4 2009-12-03 00:34:54

dw0rm
Member
Registered: 2009-12-02
Posts: 8

Re: node.js

I created this example and ran it as custom app listening on port.

Code:

var sys = require('sys'), 
   http = require('http');
http.createServer(function (req, res) {
  setTimeout(function () {
    res.sendHeader(200, {'Content-Type': 'text/plain'});
    res.sendBody('Hello World');
    res.finish();
  }, 2000);
}).listen(40740);
sys.puts('Server running at http://127.0.0.1:40740/');

When i open it in browser, it outputs

Code:

b
Hello World
0

Do you know why it appends extra symbols to just "Hello World"?

At the same time when I run this on server, the output is correct:

Code:

curl http://127.0.0.1:40740
Hello World

Last edited by dw0rm (2009-12-03 00:42:01)

Offline

 

#5 2009-12-03 03:21:09

tie
Administrator
Registered: 2007-05-21
Posts: 266

Re: node.js

It looks like this is a result of the 'chunked' Transfer-encoding set by the node.js server. Could you have the server not send the 'Transfer-Encoding: chunked' header?

Another option is to buy a dedicated IP address, and run your server on a custom unprivileged port number, so you can access it as http://your-domain.com:40740

Offline

 

#6 2009-12-03 03:40:31

dw0rm
Member
Registered: 2009-12-02
Posts: 8

Re: node.js

tie,

Thanks for your tip. I'm gonna post the question on  node.js google group.

Offline

 

#7 2009-12-03 08:10:11

dw0rm
Member
Registered: 2009-12-02
Posts: 8

Re: node.js

They helped with a patch, this is groups thread for somebody who might run into same problem:

http://groups.google.com/group/nodejs/b … 9f5be21be1

Offline

 

#8 2009-12-03 10:13:40

tie
Administrator
Registered: 2007-05-21
Posts: 266

Re: node.js

That's great! Hopefully the patch will make it into the next release. In any case, we'll keep it in mind in case anyone else runs into the same problem.

Offline

 

#9 2010-03-15 14:43:14

rschiavi
Member
Registered: 2010-03-15
Posts: 2

Re: node.js

got this all running as a locally accessible app, is there any suggestion on how to route my domain hosted to hit this service?

my only thought is i have to wrap an existing framework (django/whatever) to proxy the calls mydomain.com, to the internal localhost:port ?

thanks,

Offline

 

#10 2010-03-15 15:29:38

dw0rm
Member
Registered: 2009-12-02
Posts: 8

Re: node.js

I simply used "Custom app (listening on port)" app type, and ran node.js app under screen.

Offline

 

#11 2010-03-15 17:39:52

mae
Member
Registered: 2006-10-14
Posts: 445

Re: node.js

That is indeed the way to go.

Offline

 

#12 2010-05-11 21:54:30

enotodden
Member
Registered: 2010-05-11
Posts: 4

Re: node.js

Since you already started this thread I'll post my question here..
I'm not getting tests to run at all with node.. Building seemed to go nicely along, also all of the built in self tests I've tried works, but im not getting a response in the browser when using the custom app(listening on port) feature.. Do I have to build node in the webapps/mywebappsname directory to make it work correctly or something?

Offline

 

#13 2010-05-11 22:11:05

klynton
Administrator
From: Utah
Registered: 2009-08-31
Posts: 429
Website

Re: node.js

Hi,

Yes, you need to build node in the custom-app-listening on port directory.

Offline

 

#14 2010-05-11 23:39:20

enotodden
Member
Registered: 2010-05-11
Posts: 4

Re: node.js

Actually I made it work without building a new instance in the application directory.. Don't know how but it works now:)

Offline

 

#15 2010-05-11 23:42:38

klynton
Administrator
From: Utah
Registered: 2009-08-31
Posts: 429
Website

Re: node.js

Great! Good luck.

Offline

 

#16 2010-05-12 00:11:20

enotodden
Member
Registered: 2010-05-11
Posts: 4

Re: node.js

Anyways, made a howto for other users that wish to set up nodeJS on their Webfaction account.
http://enotodden.net/nodejshowto-webfaction.txt

Offline

 

#17 2010-05-18 07:25:47

markashleybell
Member
From: Plymouth, UK
Registered: 2010-05-18
Posts: 2
Website

Re: node.js

enotdden, that how-to link seems to be dead; could you post it here please? Would be a great help.

Offline

 

#18 2010-05-26 05:12:56

enotodden
Member
Registered: 2010-05-11
Posts: 4

Re: node.js

@markashleybell
I'm so sorry for the late answer, haven't been on the webfaction forums lately.. You've probably figured it out by now, but anyways... Here you go:


How to set up nodeJS on Webfaction.


Version: 0.1.94
Date: 12.05.10
By enotodden

1. Fire up a shell.

2. Get the .tar.gz file from nodejs.org
    wget http://nodejs.org/dist/node-v0.1.94.tar.gz

3. Extract the archive.
    tar -zxvf  node-v0.1.94.tar.gz

4. cd into directory.
    cd nodev0.1.94

5. Configure with the --jobs flag.
    ./configure --jobs=1 --prefix=$HOME

6. Build.
    make

7. Install
    make install

8. Thats it, lets test it!


9. Go to the control panel, make a new application,
set the type to custom(listening on port) and call it nodetest.
Write down the port number your app was assigned. (for this example I'll use 54321)

10. Make a new subdomain for your testing app.

11. Make a new website entry, set domain and application accordingly.

12. cd into your apps'  directory.
    cd ~/webapps/nodetest/

13. make a new file called nodetest.js
    nano nodetest.js

14. Paste in this code and save it(ctrl-o  enter  ctrl-x)
    var sys = require("sys"),
    http = require("http");

Offline

 

#19 2010-06-05 21:38:19

dshaw
Member
Registered: 2010-06-05
Posts: 3

Re: node.js

Hi,

I got my site up and running brilliantly with Node (node.dshaw.com), but  have no idea how to keep the service up?
Currently, I login and run "node dshaw.js" and it works great. However, when I close my SSH session, down goes the site. I want to leave that process running. Is that possible with a custom script configuration? Any suggestions?

Cheers,

@dshaw

Offline

 

#20 2010-06-05 21:42:11

klynton
Administrator
From: Utah
Registered: 2009-08-31
Posts: 429
Website

Re: node.js

Your best option would be to use nohup, here is a full set of documentation for it: http://www.cyberciti.biz/tips/nohup-exe … rompt.html

Offline

 

#21 2010-06-05 22:17:16

dshaw
Member
Registered: 2010-06-05
Posts: 3

Re: node.js

@klynton

Thanks. That's excellent.
Any tips on killing the process when it comes time to do that?

Cheers,

@dshaw

Offline

 

#22 2010-06-05 22:19:14

klynton
Administrator
From: Utah
Registered: 2009-08-31
Posts: 429
Website

Re: node.js

To kill the process just do this:

ps -u username -o pcpu,rss,pid,command

Then run kill PID for your application.

Offline

 

#23 2010-06-05 22:28:49

dshaw
Member
Registered: 2010-06-05
Posts: 3

Re: node.js

@klynton

Brilliant. Thank you so much. Working like a charm now.

- @dshaw

Offline

 

#24 2010-06-05 22:34:07

klynton
Administrator
From: Utah
Registered: 2009-08-31
Posts: 429
Website

Re: node.js

Great! Glad I could help. smile

Offline

 

#25 2010-06-29 00:44:46

nateanderson
Member
Registered: 2009-01-20
Posts: 11

Re: node.js

I created a node install script and made a post about it.  See http://forum.webfaction.com/viewtopic.p … 060#p17060 for details.  I hope the script is helpful.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson