Docpad and openshift - node.js

Has anyone been able to get docpad up and running on openshift paas? If so, how do you do it? I've configured the port in the environments section of the docpad.coffee file to "process.env.OPENSHIFT_NODEJS_PORT" and set the env to "production" - but to no avail. Trying to launch docpad from the server.js file just seems to get the application stuck in a loop of trying to start up and then closing down with an "EACCES" error.
Edit: Here's the error message
Error: listen EACCES
at errnoException (net.js:884:11)
at Server._listen2 (net.js:1003:19)
at listen (net.js:1044:10)
at Server.listen (net.js:1110:5)
at startServer (/var/lib/openshift/52deb1644382ec26f9000098/app-root/runtime/repo/node_modules/docpad/out/lib/docpad.js:4134:25)
at /var/lib/openshift/52deb1644382ec26f9000098/app-root/runtime/repo/node_modules/docpad/out/lib/docpad.js:4204:16
at TaskGroup.<anonymous> (/var/lib/openshift/52deb1644382ec26f9000098/app-root/runtime/repo/node_modules/docpad/out/lib/docpad.js:1109:14)
at TaskGroup.g (events.js:175:14)
at TaskGroup.EventEmitter.emit (events.js:98:17)
at TaskGroup.complete (/var/lib/openshift/52deb1644382ec26f9000098/app-root/runtime/repo/node_modules/docpad/node_modules/event-emitter-grouped/node_modules/taskgroup/out/lib/taskgroup.js:556:14)
at TaskGroup.itemCompletionCallback (/var/lib/openshift/52deb1644382ec26f9000098/app-root/runtime/repo/node_modules/docpad/node_modules/event-emitter-grouped/node_modules/taskgroup/out/lib/taskgroup.js:347:17)
at TaskGroup.EventEmitter.emit (events.js:95:17)
at Task.<anonymous> (/var/lib/openshift/52deb1644382ec26f9000098/app-root/runtime/repo/node_modules/docpad/node_modules/event-emitter-grouped/node_modules/taskgroup/out/lib/taskgroup.js:405:26)
at Task.EventEmitter.emit (events.js:117:20)
at Task.completionCallback (/var/lib/openshift/52deb1644382ec26f9000098/app-root/runtime/repo/node_modules/docpad/node_modules/event-emitter-grouped/node_modules/taskgroup/out/lib/taskgroup.js:128:19)
at DocPad.<anonymous> (/var/lib/openshift/52deb1644382ec26f9000098/app-root/runtime/repo/node_modules/docpad/out/lib/docpad.js:922:18)
at ambi (/var/lib/openshift/52deb1644382ec26f9000098/app-root/runtime/repo/node_modules/docpad/node_modules/ambi/out/lib/ambi.js:23:18)
at Task.<anonymous> (/var/lib/openshift/52deb1644382ec26f9000098/app-root/runtime/repo/node_modules/docpad/node_modules/event-emitter-grouped/out/lib/event-emitter-grouped.js:38:23)
at ambi (/var/lib/openshift/52deb1644382ec26f9000098/app-root/runtime/repo/node_modules/docpad/node_modules/ambi/out/lib/ambi.js:23:18)
at fire (/var/lib/openshift/52deb1644382ec26f9000098/app-root/runtime/repo/node_modules/docpad/node_modules/event-emitter-grouped/node_modules/taskgroup/out/lib/taskgroup.js:159:23)
at b (domain.js:183:18)
at Domain.run (domain.js:123:23)
at Task.fire (/var/lib/openshift/52deb1644382ec26f9000098/app-root/runtime/repo/node_modules/docpad/node_modules/event-emitter-grouped/node_modules/taskgroup/out/lib/taskgroup.js:166:25)
at processImmediate [as _immediateCallback] (timers.js:317:15)

I was able to reproduce this and it boils down to not being able to specify a listening address in the docpad.coffee. I've messaged the maintainers to see what can be done to change that.

As niharvey pointed out, we need to tell docpad to listen on a specific address.
In version 6.58 of docpad the "host" option was added to the environments section of the docpad.coffee file. So it needs to have the following section:
environments:
development:
# //Always refresh from server
maxAge: false # default
# //Listen to port 9778 on the development environment
port: 9778
production: # //this is the important part for openshift
# //this is the part that open shift needs -
# //but its only available in docapd 6.58+
hostname: process.env.OPENSHIFT_NODEJS_IP
port: process.env.OPENSHIFT_NODEJS_PORT

Related

How to fix Kotlin Reactjs tutorial error: listen EADDRINUSE

As part of this basic tutorial, I downloaded the code from this repo, and attempted to run it with the command ./gradlew run on an Ubuntu 20.04 environment.
This resulted in the following error:
> Task :browserDevelopmentRun
✖ 「wds」: Error: listen EADDRINUSE: address already in use 127.0.0.1:8080
✖ 「wds」: Error: listen EADDRINUSE: address already in use 127.0.0.1:8080
at Server.setupListenHandle [as _listen2] (net.js:1318:16)
at listenInCluster (net.js:1366:12)
at GetAddrInfoReqWrap.doListen [as callback] (net.js:1503:7)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:69:8) {
code: 'EADDRINUSE',
errno: -98,
syscall: 'listen',
address: '127.0.0.1',
port: 8080
}
The process seems to be the only one running on this port, and attempts to get rid of any other processes using port 8080 (sudo kill -9 'sudo lsof -t -i:8080', killall node, etc...) have no effect. The conflicting processes seem to both come from within the tutorial web app.
Changing the port using a .env file also did not work. No matter what port is set (8081, 3000, 83000, etc...), there is still the error of port 8080 already being in use.
Does anyone know a solution to this issue? Thanks!
So while I didn't figure out exactly which dependency was causing this issue, on trying out a couple of the pull request on the repository, I found that this one: https://github.com/kotlin-hands-on/web-app-react-kotlin-js-gradle/pull/11 fixes the problem. Hopefully, it will be merged into the main branch soon!

I'm trying to deploy a node server to heroku and I'm getting this error: throw er; // Unhandled 'error' event

I'm trying to deploy a node app to heroku and it looks like judging from other questions that heroku is dynamically assigning a port and it is somehow incompatible with something.
(I had to remove some details to post the question)
events.js:182
throw er; // Unhandled 'error' event
^
Error: listen EACCES 0.0.0.0:80
at Object._errnoException (util.js:1041:11)
at _exceptionWithHostPort (util.js:1064:20)
at Server.setupListenHandle [as _listen2] (net.js:1305:19)
at listenInCluster (net.js:1370:12)
at Server.listen (net.js:1466:7)
at Function.listen (/app/node_modules/express/lib/application.js:618:24)
at Object.<anonymous> (/app/index.js:9:21)
at Module._compile (module.js:573:30)
at Object.Module._extensions..js (module.js:584:10)
at Module.load (module.js:507:32)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! TFP#1.0.0 start: `node index.js`
npm ERR! Failed at the TFP#1.0.0 start script.
Problem
I had the same issue. I ran into this problem when I tried to set the port manually:
app.listen(80, function () {
console.log('Example blog app listening on port 80!')
});
This led me to the same EACCES error.
Solution
I was able to solve the problem by going back and looking through the Heroku docs where I found:
The command in a web process type must bind to the port number specified in the PORT environment variable. If it does not, the dyno will not start.
So, assuming you're using express, if you switch the port assignment to look something like this:
app.set('port', (process.env.PORT || 5000));
app.listen(app.get('port'), function() {
console.log('Node app is running on port', app.get('port'));
});
Then you application should start properly.
Solution without Express.js
If you are not using Express, then you can set the port simply as:
var PORT = process.env.PORT || 5000;
Where process.env.PORT will be your production port, and 5000 will be the port you would use when testing your server locally.
I have faced this kind of problem. The exact error is the port 80 is already enabled in another project or app. So before start your app, stop the other app mapped to 80 port.
Now you can run your app without this error.
Thanks

Cloud9 + sails.js + phpmyadmin

I have problem with creating basic sails.js application on Cloud9 environment and connecting it to MySQL.
Steps I'm making:
Creating Cloud9 project
installing sails: npm -g install sails
creating project: sails new test
lifting: cd testProject/ and sails lift
Here it's working
Adding mySQL support: mysql-ctl start
still working
adding phpMyAdmin support: phpmyadmin-ctl install
And here, my application stops working. I'm getting exception:
events.js:72
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE
at errnoException (net.js:905:11)
at Server._listen2 (net.js:1043:14)
at listen (net.js:1065:10)
at Server.listen (net.js:1139:5)
at Array.async.auto.start [as 0] (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/lib/hooks/http/start.js:29:35)
at /home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:484:38
at _each (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:46:13)
at Object.async.auto (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:455:9)
at Sails.startServer (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/lib/hooks/http/start.js:16:11)
at Sails.emit (events.js:92:17)
at Sails.emitter.emit (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/lib/app/private/after.js:50:11)
at afterBootstrap (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/lib/app/private/initialize.js:56:11)
at bootstrapDone (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/lib/app/private/bootstrap.js:51:14)
at Object.module.exports.bootstrap (/home/ubuntu/workspace/testProject/config/bootstrap.js:16:3)
at Sails.runBootstrap (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/lib/app/private/bootstrap.js:44:25)
at Sails.bound [as runBootstrap] (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/lodash/dist/lodash.js:729:21)
at Sails.initialize (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/lib/app/private/initialize.js:48:9)
at bound (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/lodash/dist/lodash.js:729:21)
at /home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:607:21
at /home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:246:17
at iterate (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:146:13)
at /home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:157:25
at /home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:248:21
at /home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:612:34
at /home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/lib/app/load.js:201:13
at /home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:451:17
at /home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:441:17
at _each (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:46:13)
at Object.taskComplete (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:440:13)
at processImmediate [as _immediateCallback] (timers.js:354:15)
Additionally I'm getting info about problem with starting my app, and ability to kill the process. Of course killing does not help.
Could youplease help me with that?
So what's happening is that you're starting your sails server, which binds to port 8080, and then you try to install phpmyadmin which tries to start apache (at port 8080 too!) causing it to actually fail since the port is already in use. You will have to stop sails before trying to install / run phpmyadmin since two servers can't listen on the same port.

npm start giving error

I have installed KrakenJs on Windows 7. I have created project by using following command :
Yo Kraken
When I tried to run the project, it is giving following error (even after restarting system) :
E:\nodejs\test\kraken\Dust-01>npm start
> dust-01#0.1.0 start E:\nodejs\test\kraken\Dust-01
> node index.js
Error: listen EACCES
at errnoException (net.js:901:11)
at Server._listen2 (net.js:1020:19)
at listen (net.js:1061:10)
at Server.listen (net.js:1127:5)
at bind (E:\nodejs\test\kraken\Dust-01\node_modules\kraken-js\index.js:139:33)
at _fulfilled (E:\nodejs\test\kraken\Dust-01\node_modules\kraken-js\node_modules\q\q.js:798:54)
at self.promiseDispatch.done (E:\nodejs\test\kraken\Dust-01\node_modules\kraken-js\node_modules\
q\q.js:827:30)
at Promise.promise.promiseDispatch (E:\nodejs\test\kraken\Dust-01\node_modules\kraken-js\node_mo
dules\q\q.js:760:13)
at E:\nodejs\test\kraken\Dust-01\node_modules\kraken-js\node_modules\q\q.js:574:44
at flush (E:\nodejs\test\kraken\Dust-01\node_modules\kraken-js\node_modules\q\q.js:108:17)
E:\nodejs\test\kraken\Dust-01>
Can some one guide me what I am doing wrong and how it can be rectified
Look into next two possibilities:
Try opening your command prompt 'As Administrator', that shall solve the issue if you are lacking permissions to open port.
Temporarily change the port used in Kraken to something irregular and long, example: 32482
Then move on from this, if 1st - then you have solved an issue, if 2nd - you are very likely trying to open a port, which is already used by other application.

Node.js Unhandled 'error' event when using http.createServer().listen() on Ubuntu 12.04

Salam (means Hello) :)
I've developed a node.js script on my windows seven machine and it's working fine. but when I run it on my Ubuntu 12.04, the following error shows up and halts my app:
throw er; // Unhandled 'error' event
^
Error: listen EACCES
at errnoException (net.js:901:11)
at Server._listen2 (net.js:1020:19)
at listen (net.js:1061:10)
at Server.listen (net.js:1127:5)
at Object.start (/httpServer/httpServer.js:9:34)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
and the point that caused error is .listen(80) in this line:
http.createServer(onRequest).listen(80);
^
I've also tried some other port numbers (like 100, 300, 500,...) instead of 80 and the error was still the same.
On Ubuntu you can't listen on ports < 1024 without root privileges. Try running node under sudo.
sudo node app.js
You probably have apache running on port 80, so it's conflicting.
Use another port (NOT within 0-1023), or disable apache.
Cheers
You probably have something else running on port 80, so it's conflicting.
Read here to find out what is using port 80 and stop it
http://www.cyberciti.biz/faq/find-linux-what-running-on-port-80-command/
Usually it means another server like apache is enabled. so stop it.
sudo service apache2 stop
or You have npm start already running in another terminal
or skype is running. in which case go to settings and change it's port. logout n login
Go to Tools -> Options -> Advanced -> Connections and uncheck the box "use port 80 and 443 as alternative".src
or use another port
http-server -a localhost -p 8000
I suggest to install the latest node packets, maybe directly from Node.js server, maybe compiling it.
Try to set a port which is not reserved to any service, like 3700.
Could be heplful to see some other fragment of code, though.
This can also be caused if you have something else already listening on that port - you can try changing the port from the typical default 80 to something more like 10014 and see if that helps!
I was able to rectify the error by explicitely mentionining the "IP address" along with the port when listening to the server.

Resources