Dotcloud nodejs supervisord.conf not working - javascript

I've been trying to get my nodejs server process to be monitored by supervisor, however I'm having issues getting supervisord.conf to work. When I deploy, I get the following error:
WARNING: The service crashed at startup or is listening to the wrong port. It failed to respond on port "node" (42801) within 30 seconds. Please check the application logs.
However when I ssh into the dotcloud server and manually start the nodejs process, it runs just fine, indicating that supervisor is failing to start the node instance.
My supervisord.conf looks like this:
[program:node]
command = node /home/dotcloud/current/app/server.js
autostart=true
autorestart=true
And my directory structure is as follows:
.dotcloudignore
dotcloud.yml
.gitignore
app/
app/package.json
app/server.js
app/supervisord.conf
At this point, I can't see what I'm doing wrong, as this appears to be the same directory structure as outlined here, so I'm kind of at a loss as to what the solution is. Any ideas?
Edit:
After trying a supervisorctl status I get the following:
node FATAL Exited too quickly (process log may have details)
I've found that in /var/log/supervisor, I'm getting the following error message:
module.js:337
throw new Error("Cannot find module '" + request + "'");
^
Error: Cannot find module '/home/dotcloud/current/app/server.js'
at Function._resolveFilename (module.js:337:11)
at Function._load (module.js:279:25)
at Array.0 (module.js:484:10)
at EventEmitter._tickCallback (node.js:190:38)
I'm not sure what is causing this.

After investigating the issue, it looks like the issue came from the fact that dotcloud.yml specified approot: app. In that case, it is useful to note that:
/home/dotcloud/code will point to the whole code repository;
/home/dotcloud/current will point to the approot (more specifically, /home/dotcloud/current will be a symlink to the approot, i.e. code/app in that case).
Therefore, supervisord.conf should not contain:
command = node /home/dotcloud/current/app/server.js
But, instead:
command = node /home/dotcloud/current/server.js
The key was in the Node.js logs themselves, since Node.js was complaining about being unable to locate /home/dotcloud/current/app/server.js.

Related

React Native -- cannot start because HTTP server already being used by another WebSocket server

I'm running npx react-native start/npx react-native run-android, and everything builds fine; however, the app cannot start a server properly. This is the error I'm getting:
Error: The HTTP/S server is already being used by another WebSocket server
at new WebSocketServer (.../node_modules/ws/lib/websocket-server.js:83:15)
at Object.attachToServer (.../node_modules/react-native/node_modules/#react-native-community/cli/build/commands/server/messageSocket.js:93:15)
at Object.runServer [as func] (.../node_modules/react-native/node_modules/#react-native-community/cli/build/commands/server/runServer.js:127:37)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Command.handleAction (.../#react-native-community/cli/build/index.js:164:9)
I've tried killing all react-native related processes, and even if I reboot the system, this error still persists. Any ideas on what might be causing this?
It looks to me like your processTicksAndRejections() method is trying to set up its own WebSocketServer instance to do its work, rather than using one that's already set up. Your error message means that you
already have an http/s server going
already have a websocket server set up on it
you're trying to set up another websocket server on that existing http/s server.
If you were trying to run two server processes on the same port, a different error message would show up.
I ended up solving this problem by removing the dependency #react-native-community/cli-platform-android altogether, but I'm not completely satisfied with the solution because I have to run npx react-native start and npx react-native run-android separately.

Syntaxerror: Unexpected Token , in Hawk (fresh npn install)

I am in the process of learning Nodejs and WebRPC. I am for all intents and purposes, a novice.
I installed the Plivo (http://plivo.com) API for nodejs and when attempting to run it I had an issue with Const which I resolved by running my test file with --harmony appended to the start of the command, after this I have gained the error
Syntaxerror: Unexpected token ,
This error falls on line 506 of
\hawk\lib\server.js
The relevant section of code is;
const artifacts = {
ts: authorization.ts,
nonce: authorization.nonce,
host,
port,
hash: authorization.hash
};
line 506 is host,
I do not see the problem.
At this point, all I am trying to do is initialise the plivo API. I have no other calls to it.
I have deleted the hawk folder and done a fresh npm install hawk, can anyone else suggest anything?
edit:
As of writing the post, I attempted to load hawk directly in a script rather than as a dependency through plivo. It still brings up the same error so it won't be a problem with plivo.
Edit 2.
Seems it was a versioning issue. My system had v0.12 installed. I attempted to update it twice, both times the install went back to v0.12 despite uninstalling it first.
Cleared appdata\roaming\npm and appdata\roaming\npm-cache as well as deleting any remaining node files in "c:\program files" before reinstalling. I now have 8.x installed and the syntax error is no longer showing.
Thanks
Ken

Node-Inspector unable to open chrome browser throwing Error ENOENT

I would like to know why am I getting the following error when I try to debug node app using node inspector.
Debugger listening on port 5858
events.js:154
throw er; //unhandled 'error' event
Error: spawn C:\Users\Dell\AppData\Local\Google\Chrome\Application\Chrome.exe ENOENT
at exports._errnoException (util.js:890:11)
at Process.ChildProcess._handle.inexit(internal/child_process.js:182:32)
at onErrorNT (internal/child_process.js:348:16)
at _combinedTickCallback (node.js:383:13)
at process._tickCallback (node.js:407:11)
I believe this error was similar to the error reported at https://github.com/node-inspector/node-inspector/issues/732. But however I didn't get as new_chrome.exe.
Any help is appreciated
node version is 5.9.1
node debug version is 0.12.7
EDIT: Actually the problem is chrome.exe file is inside "Program Files(86)" , but while running node-debug it is searching in user folder. So it is something to do with node-module browser-launcher When I run detect.js, in browser-launcher2/examples , its returning me the correct chrome.exe path, but when I run launch.js, it is returning me the above error, since it was trying to find chrome.exe inside user folder. Any thoughts on this?
UPDATE: Added the temporary solution. It worked for me.
NOTE: This is a temporary solution. I am keeping this question open, so as to get a permanent solution for this error. Happy coding :)
I solved the above issue temporarily using James-Browser-Launcher module. Just install the module and run examples/launch.js in the terminal. Once launched, your default browser would open. Now run
node-debug
it launched the browser without error for me. Thats it. It would work now. Hope it works for you too
This works for me:
Go to C:\Users\youruser\ .config\browser-launcher2
open config.json
If there are more than two instances of Chrome, uninstall the error instance first and delete the error entry at file and his associated folder in this path. In my case, the error was Chrome Canary :
Example
And then, node-inspector works with Standar Chrome!!!

Node.js - Server crashes when started on startup, doesn't crash when manually started

I am running Node.js and Socket.io for online chat.
I have created a file in:
/etc/init/example.conf
it has two lines:
start on startup
exec forever start /var/www/example.com/html/server.js //location of server file.
Whenever I start file upload in chat application, it crashes but instantly restarts.
Whenever I kill node process though, and start it manually - it works fine.
I also can't get any logs or anything from terminal as when it's auto started - it doesn't print me anything to terminal.
I am still new to Node.js and Linux in general.
Node.js is running on Express + Jade.
How do I determine specific cause?
I managed to solve my problem, after a bit of searching around I found out about tail command.
My issue was a bit harder to trace because Node.js was a process started by autostart so when I launched terminal and connected to server, process was just running in background basically and I wouldn't get any output (including exception messages).
Anyway, solution that worked for me was:
I typed
ps aux | grep node //to find PID of node process
then I went to following directory
cd /proc/[pid of running node service]/fd
In fd directory there are few objects you can get output from but if you want to attach and listen to servers output including uncaught exceptions, you need 1.
So:
tail -f 1
that way I was able to cause website to crash and see the output.

Bogart in NodeJS 0.6.10 on Windows Fails to start with message about 'sys' module

I've been learning how to use Bogart (v 0.3.38) under NodeJS (Windows, v 0.6.10), but I can't even get the basic "hello world!" to work, even though I think it must be a problem with the runtime and Bogart.
I'm using the example listed here just try to make it run. At the beginning, I got this message:
The "sys" module is now called "util". It should have a similar interface.
Then I went through all the files in the folder I'm creating the app and change "sys" to "util" in the require statement, and that, for while, got ride of the message above, but then I started getting a message that said that bogart could not access the isRouter property of undefined, that's when I decided to use the "Hello World" example to see if I was doing something wrong.
Now I get the "sys to util" message mentioned above, a message about the server starting on port 8080 and then a stacktrace:
The "sys" module is now called "util". It should have a similar interface.
Server running on port 8080
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: listen EACCES
at errnoException (net.js:646:11)
at Array.0 (net.js:732:28)
at EventEmitter._tickCallback (node.js:192:40)
Any clues of what might be wrong here?
As always, thanks in advance!
Found the problem: I had another application running on the same default port (8080) of Bogart, changed the port and everything worked.
In my case it was an error of mysql2 connection after update of MySQL config.

Categories

Resources