googlecreativelab / coder

A simple way to make web stuff on Raspberry Pi
http://goo.gl/coder
Apache License 2.0
2.42k stars 276 forks source link

Best way to see the console.log() print out when logged into the Pi thru SSH? #50

Closed jmp407 closed 10 years ago

jmp407 commented 10 years ago

I've searched the internet far and wide for an answer to this, but can't find it. Requests to print to the console.log don't show up in my http coder session or the ssh session on my laptop and I don't have a tv connected to the Pi. Help!

Code-nomad commented 10 years ago

Pipe it to a text file. Should be an easy fix. Op 22-okt.-2013 14:41 schreef "jmp407" notifications@github.com:

I've searched the internet far and wide for an answer to this, but can't find it. Requests to print to the console.log don't show up in my http coder session or the ssh session on my laptop and I don't have a tv connected to the Pi. Help!

— Reply to this email directly or view it on GitHubhttps://github.com/googlecreativelab/coder/issues/50 .

jmstriegel commented 10 years ago

In a pinch, you can ssh in and restart coder from the command like:

sudo /etc/init.d/coder-daemon stop sudo su coder cd ~/coder/coder/coder-base nodejs server.js

When you're done, ctrl-c to kill coder. exit to get back to the pi user. sudo /etc/init.d/coder-daemon start to start things back up.

If you need this a lot, it might be useful to override console.log in the server.js app to have it print to a file...

jmp407 commented 10 years ago

Thanks a bunch. Will try it tonight. Just trying to debug my typos etc. I'm always open to suggestions. By the way, thanks for putting coder out there.

On Tue, Oct 22, 2013 at 3:05 PM, Jason Striegel notifications@github.comwrote:

In a pinch, you can ssh in and restart coder from the command like:

sudo /etc/init.d/coder-daemon stop sudo su coder cd ~/coder/coder/coder-base nodejs server.js

When you're done, ctrl-c to kill coder. exit to get back to the pi user. sudo /etc/init.d/coder-daemon start to start things back up.

If you need this a lot, it might be useful to override console.log in the server.js app to have it print to a file...

— Reply to this email directly or view it on GitHubhttps://github.com/googlecreativelab/coder/issues/50#issuecomment-26839680 .

The problem is... Jan Pottinger 5207 Applerock Dr. O'Fallon MO 63368 636 542 8556 636 542 1017

jmp407 commented 10 years ago

The first two lines seemed to work but not the cd I have a newer version of node.js (0.10.9) so nodejs refused to run server.js

jmstriegel commented 10 years ago

Oops. I typoed the directory. Just cd to the coder-base folder inside your coder home directory. I don't have access to my Pi right this second, but I think it's ~/coder-dist/coder-base.

jmp407 commented 10 years ago

That's what I did but node 0.10.9 was not available and nodejs would not start the server.js

On Tue, Oct 22, 2013 at 6:44 PM, Jason Striegel notifications@github.comwrote:

Oops. I typoed the directory. Just cd to the coder-base folder inside your coder home directory. I don't have access to my Pi right this second, but I think it's ~/coder-dist/coder-base.

— Reply to this email directly or view it on GitHubhttps://github.com/googlecreativelab/coder/issues/50#issuecomment-26865563 .

The problem is... Jan Pottinger 5207 Applerock Dr. O'Fallon MO 63368 636 542 8556 636 542 1017

jmstriegel commented 10 years ago

What kind of errors do you get when you run "node server.js"? Sounds like this may be a different issue than not being able to see console.log messages.

Do you have the raspbian distro's version of node (apt-get nodejs) installed in /usr/bin/? You might want to use that until things are resolved for 0.10.9. I've been sticking with what's current in the raspbian packages, assuming that it's what most people have deployed -- would be curious to see what needs to be modified to work in 0.10.9.

mrutgerj commented 10 years ago

Going to chime in for a second... In my experience, I could never 'su coder' because its bash is set to 'none'

sudo cat /etc/passwd // results in: coder:x:112:112:Coder daemon,,,:/home/coder:/bin/false

Never mind the red X, github markdown flew that bird. When I am pi, and try to launch node or nodejs (coder) from the coder dir, I get mostly path not found exceptions for /app/auth/login path.

Right now, messing around with other versions of node, I am getting permission errors if I try that. BUT I have been doing screwy things with groups and files. It will probably give you the path not found exception.

My node versions are upgraded out of necessity, to use node-inspector, and other modules. Node-inspector is a half-decent debugger, but a half-arsed IDE, wrought with confusion and frustration. But I'm rolling with it, so I love it for the debugging it offers me. Those console logs tell one side of the story. If you go to the client-side network tab when an internal error occurs, you can click on the URL ('preview' view) and see where the code slammed ground, along with a stack of calls.

I have a couple of articles about node-inspector and the necessary node.js upgrade at: www.mrjansen.com. Those articles are very hack, but I am editing them every time I refer to them. For instance, the PATH variable for npm needs to be set correctly.

jmstriegel commented 10 years ago

Right, sorry. Try: sudo su -s /bin/bash coder to force a bash shell.

If you're getting permission errors, there's a chance some of the files are owned by another user. Try setting ownership recursively on the entire coder directory to coder:coder. chown -R coder:coder ~coder/coder-dist.

Sounds like you've got a pretty unconventional setup, but hopefully at this point you can at least launch it from the command line and see the logs and any errors you are getting, even if it's crashing. From there it should be possible to work through the log output and figure out what needs to be tweaked to work with your settings.

jmp407 commented 10 years ago

No problem @jmstriegel I've been known to make a typo myself. But after reading @mrutgerj 's comment and site at the link, I'm going to go node-inspector. I'm pretty sure this is where my node 10.9 came from but I stopped short of loading node-inspector. I'll proceed with that this evening and see how far I get. @mrutgerj , btw I have a DHT22 that is my sensor of choice since I need Rh and T. I look forward to more posts, but maybe this issue should be closed?

mrutgerj commented 10 years ago

@jmp407 That's a good idea for a post! I'm stuck on i2c since the bus is crashing everytime I access it over node. I have some DHT temp / humidity sensors, and I'll look at writing up a webapp howto, via the onoff io library. If you can email me on my blog, I'll email you back when said article is done (too bad there is no PM'ing on here any longer!).