How to get output of Node.js' console.log on Namecheap shared hosting? - node.js

I signed up for Namecheap hosting because in addition to PHP they also offer Node.js hosting.
I've figured most of it out so far. But is there a way to get output of console.log() on a shared hosting environment such as Namecheap.com ? Even redirecting output to a text file that I examine after the fact via FTP would be a help.
When developing on my local computer I can use my web browser browser tools to see the console on the server side. But that of course doesn't work on the shared hosting server side (namecheap).
Thanks !

I have discovered a solution that at least gets me the desired effect (indicated in bold italics above):
I simply used the console.error() function instead of console.log().
Then I am able to examine the stderr.log to see the messages indicating progress in the app.
FWIW I will formulate a better, separate question regarding console.log() use & do more research in using SSH to see what I can find using that approach.

Related

Node.js and ColdFusion on the same server?

I have question about how to set Node.js server application. On my server I have ColdFusion application server. I can test my code through browser url. I would like the same for Node.js. Node is already installed on my server but the only way to run the code is through cmd command window. First question is what I need in order for both to run on the same server? I still need my ColdFusion. Second question is about Nodes.js and can I set up server application with ISS or I need something else? Also do I have to specify what extension on my files will point to ColdFusion and other to Node. For example .cfm extension is for ColdFusion and .js is for the Node. If anyone knows anything about this or where I can find more information please let me know. I never experienced something similar and this is something completely new for me.
I know this is an old post but I figure I'd provide an answer for those souls who are looking around.
If working with Apache 2.4.x.
In a test environment this would not be to much of an issue as Node and Coldfusion operate on different ports.
If your looking to create a production site than I would say that building a virtual host with proxy to the node site and Coldfusion would be another method.
If you are using the Coldfusion connector to Apache and loading node, than still loading the proxy for the node part would be fine, just make sure you are pointing to the correct port for your node.
Things to remember:
You may have to alter internal Firewall rules.
Comment your hosts files so you don't accidentally alter the wrong file.
Both can exist within the same platform.

Running vline-node example on IIS

I have successfully tested the vline-node example locally, but would like to push it out to a server. I have tried to install the example as an application on an IIS8 website, placing the example code under wwwroot. I have done tried this both within the root and inside a virtual directory, pointing to the views folder. I am able to login to the application from a browser on the server, although, since javascript is turned off on the server browsers for security, so functionality is missing.
However, when I try to access the site from a remote browser I am not able to login. Actually, I can see that there is something wrong with my paths, as the include files are not found.
The more I've thought about this the more confused I've become. I'd like to run this under IIS, but wonder if that makes sense. Can someone offer a clean solution for hosting the vline-node example on a Windows Server, ideally under IIS?
Since you are using the node example, you'll need to make sure that node is actually running on your IIS server. Here's a SO response that may be helpful: How to run Node.JS server for a web application?
Note that in our node example the "main" file is vline-node.js, so use that in place of the app.js that is mentioned.

Console & Logging In Node.js From A HTTP interface

I have a difficult question that needs some answering, i have seen some projects where
the application runs a socket in a browser that has a console like format that the user can run for their node.js module...
If the actually calling a function or script is impossible from the web side,
i think it would be nifty to just see the console logs in the window.
If any advice could be shared, that would be amazing!
Thanks :)
Yes, there are several projects that do this. Weinre is very commonly used. You can look at its source code to see how it does it.
If I were to build it from scratch, I would utilize Socket.IO. Send the command, return the result.

How do you get a server to upload and work for your game?

I've been searching all over the web and have attempted to upload my node.js based server up to a few various web hosters with no result. As far as I know most hosters don't support node.js to begin with, and I have a list of a few that do.
But my primary question is, how do you get your server working on this hoster in the first place? do you just upload it? does it sort of self run once uploaded? do I have to access that hosters cmd in order to get it running?
Sorry for what is probably a very newbish question, which I assume it is as I have yet to find a guide that covers this because it is apparently too basic. They always seem to skip this part:s
You'll just need to upload your files to a web host that supports javascript and offers command line access; for example, check out Amazon's free scalable offering. Once you have the files uploaded, just run them from the command line:
% node node.js

How to replace IIS with Node.js for simple websites

I am coming from Microsoft world so please bear with me on this. I was told I could install node.js and use that as a web server instead of IIS. This is a very small business application. In IIS I can create virtual directory and point to the location of the web page and everything works just fine. Based on very little I read, I have few questions;
Is it possible to run node js as a windows service or any other form so that it runs for ever? I did find the forever package that I think I can use.
In IIS, I can create virtual directory set the port and thats it, I have myself a website.
I do not see any examples where I can use a directory where I have a web page, written in java script and point it to run as a web site. All the examples have some thing like server.js and that runs and routes the call. what is the other way to host web sites and use node.js to simple run as a fast web server.
I was told I could install node.js and use that as a web server instead of IIS.
This is true, but as you already found out then you are in charge of providing for things that IIS was already doing for you (e.g. automatically restart on reboot, or on crashes, hosting multiple sites by creating virtual folders, et cetera.)
You can indeed get all of these things worked out in Node.js and there are several libraries that help on each of these areas. It's not too hard but you'll need to do a bit of researching.
You can also run Node.js behind IIS. Take a look at iisnode http://tomasz.janczuk.org/2011/08/hosting-nodejs-applications-in-iis-on.html
Is it possible to run node js as a windows service or any other form so
that it runs for ever?
The library Forever takes care of restarting the site when it crashes...but I don't know if you can run it as a Windows Service. I haven't tried that.
In IIS, I can create virtual directory set the port and thats it,
I have myself a website.
I assume you are talking about a site that serves static HTML files, right? If that's the case that's very easy to support in Node.js either writing your own web server or using Express.js to serve static files.
I do not see any examples where I can use a directory where I have a web page,
written in java script and point it to run as a web site. All the examples
have some thing like server.js and that runs and routes the call.
Here is an extremely simple example to serve plain HTML files in Node.js https://gist.github.com/2573391 Don't use this in production, though. It's just an example and it does not have any kind of error handling or security.
what is the other way to host web sites and use node.js to simple run
as a fast web server.
As others have said, you should look into Express.js http://expressjs.com/ It provides some of the infrastructure that you are very likely going to need when building traditional web sites.
You say you're running a "very small business application" behind IIS. Unless it's written for Node.js (in JavaScript), it won't work.
There are no examples pointing to a directory and running that as a website, because that's not how things are done in Node.js. You write a Node.js-application and pull in a webserver-library.
Put simply, In Node.js, you don't embed the appliation in the webserver; you embed the webserver in the application.
When I used node.js, I redirected HTTP requests by a proxy server, nginx. I don’t know if you can directly bind node.js as an HTTP server, but for what’s it worth, nginx is pretty nice!
First things first, allow me to share an introduction. IMHO you should take this decision ( of moving from IIS to nodeJS) by adding various parameters. I belong to the Java & PHP community yet I use NodeJS to achieve extremely specific implementation where NodeJS perform the fastest ( fast IO, AJAX-JSON responses & more ). As you are coming with a Microsoft background you should bare with less comfortable solutions.
Yes, its possible to run NodeJs as a windows service and Forever will do fine.
and yes you can create "Virtual Directories" but by creating symbolic links to each of your customer's web site.
I recommend to take a good look at bouncy & express, If you're willing to take this step then these packages is just what you need.
Cheers!

Resources