Previously, it was developed locally, directly accessing the directory where the program is located, and then nodeserver. javaScript can be run. now I have a server directory bukemall. comgaoqiang... in this way, I can access my main program file, but how can I start it? I have been working locally and directly go to the program directory. then node server. js can run. now I have a server directory.
Http://bukemall.com/gaoqiang...
In this way, I can access my main program file, but how can I start it?
Reply content:
I have been working locally and directly go to the program directory. then node server. js can run. now I have a server directory.
Http://bukemall.com/gaoqiang...
In this way, I can access my main program file, but how can I start it?
You can also execute node server. js on the server;
However, execute the command on the server and switch it to the backend:
Nohup node server. js> myLog. log 2> & 1 & // replace node server. js
In this way, your program will be switched to the background for execution, and a myLog. log and log will be generated. related errors will also be recorded in the log;
Of course, there are some advanced tools like pm2, which will be more convenient .... However, the general purpose is to allow your program to run on the server in the background;
Google pm2
Go to the program directory on the server, and thennode server.js
You can.
A locally developed computer can also be considered as a server.
Samenode server.js
You only need to configure the port when the server can be accessed. if port 80 is not occupied, use port 80 directly. if port 80 is occupied, use other ports. If nginx already exists, a second-level domain name is used for reverse generation. Open the firewall to allow access directly using other ports. To restart the server, you can use the pm2 mentioned above to automatically restart the node.
Thank you for your invitation. we can see that the weekend is over.
After reading your source code,
I don't know what your chatServer is doing .. It seems like an example of websocket testing for im chat.
You only need node server. js to start it, and you need to enter your Directory. if not, add node xxx/server. js to the front.
Xxx indicates your Directory
I personally suggest using supervisor to monitor code, automatically restart, and print log errors, which is suitable for development and debugging.
Reference github https://github.com/petruisfan...
After installation, the supervisor -- debug server. js is started.