How does the Javascript-nodejs program run on the server?

Source: Internet
Author: User
has been developed locally, directly into the directory of the program, and then node Server.js can run, and now I have a server directory
http://bukemall.com/gaoqiang/...

This gives you access to my main program file, but how do I start it?

Reply content:

has been developed locally, directly into the directory of the program, and then node Server.js can run, and now I have a server directory
http://bukemall.com/gaoqiang/...

This gives you access to my main program file, but how do I start it?

You can also execute node server.js on the server;

However, execution on the server can be properly cut into the background:

Nohup node server.js > MyLog.log 2>&1 &//This sentence instead of node server.js

This way your program will be cut into the background to execute, and generate a myLog.log and logs, related errors will be recorded in the log;

Of course, there are some advanced tools like PM2 that would be more convenient .... But the general purpose is the same so that your program on the server can be run in the background;

Google PM2

When the server enters the directory where the program is located, then node server.js you can.
Locally developed computers can also be viewed as a server

The same node server.js , only to be able to be accessed in the server needs to configure the port, if the 80 port is not occupied then the direct use of 80, if it is occupied with the other port. If you already have nginx then do a two-level domain name reverse. If you access directly with a different port to open the firewall allows access. In order to restart the server can also automatically restart node, you can use the PM2 mentioned above

Xie invited, only to see that the weekend is finished.

Look at your source,

I don't know what you are doing with this chatserver. It feels like an example of a websocket test used to do im chat.

You start with node Server.js only if you enter into your directory, and if not, add node xxx/server.js to the front.

XXX indicates your directory

Personal suggestion development using supervisor can listen to code, automatic restart, print log error, very suitable for development debugging

Refer to GitHub Https://github.com/petruisfan ...

After installation, Supervisor--debug Server.js is started.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.