WebFaction
Community site: login faq

I used the one click installer to create a Node.js app. The "hello world" that is created with the installer worked fine but I'm not able to get the app I've been working on to work on the site (it's been working locally with no problem but on the site I get a page that says "Not implemented").

There's some console.log statements that I've put in the app to debug it but whenever I run the start script from the shell I don't see any statements appear. So where are console.log statements for an app supposed to appear?

asked 10 Feb '14, 18:57

Gigamech
1525
accept rate: 0%


console.log() goes to stdout, and console.error() goes to stderr.

Unfortunately, as it stands right now, both of those streams are discarded. A "start" script via the one-click installer has a line that looks like this:

nohup /home/username/webapps/appname/bin/node /home/username/webapps/appname/app.js > /dev/null 2>&1 &

nohup discards output anyway, so everything is sent straight to /dev/null. This means that most people using node via our one-click installers do not use console.log or console.error for debugging. Instead, you would create a function which appends to a log file using file I/O, and that file can be created anywhere you like.

For instance:

var fs = require('fs');
var log = function(msg) {
    fs.appendFileSync('/home/username/webapps/appname/debug.log', msg + '\n');
};

Then, you can just log("something");

Hope that helps!

permanent link

answered 11 Feb '14, 01:50

ryans ♦♦
5.0k103660
accept rate: 43%

edited 11 Feb '14, 01:51

Thanks for clearing that up. Any plans to modify the one-click installer to allow normal use of stdout? Also any way to get a stack trace or some indication of what's wrong with a Node script if it crashes?

(11 Feb '14, 22:40) Gigamech
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×67
×10

question asked: 10 Feb '14, 18:57

question was seen: 3,009 times

last updated: 11 Feb '14, 22:42

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2020 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM