How can i run a socket.io server continuously? - javascript

i'm trying to code a whiteboard app. AND i'm using socket.io for real time comm.. To do that, i'm logging in my VPS via putty and I'm starting the server like "node server.js", but when I log off from VPS (closing putty) normally the server shuts down. So, how can I solve that problem?

in your server console hit this command firstly this will install forever module
$ sudo npm install forever -g
use sudo according to your permission in your server
then hit this command in your server console
$ sudo forever start server.js

Another alternative is to use tmux so that the terminal doesnt dies when you logout of your VPS.
For ubuntu, apt-get install byobu
and in the byobu terminal use node server.js
Then you can exit the VPS without killing the terminal process.
Not recommended for production use.

Related

NodeJS not detected over remote Powershell

Installed nodejs and npm package on windows. No problems while running commands locally, but on SSH powershell (remoting in), it says "node" command not found. Similar results from npm command too.

How to run MEAN stack in docker on local environment?

I'm new to MEAN projects and I have a new project I've successfully cloned and need to get running locally to develop against. I have no idea where to start.
It has things like docker, lerna, yarn, etc. How can I get this working on my local dev machine? I have PC and Mac resources as well as resources like Azure and AWS (Cloud9).
Update
I had to do things like the following to get it up and running. Now, this took a few minutes to run. My question now is, will I have to stop and start this process each time I make a change (the npm run dev part, I mean)?
npm -v
nvm ls
nvm install 8.9.4
node -v
nvm alias default 8.9.4
ssh-keygen
cat ~/.ssh/id_rsa.pub
git clone <repo>
copy .env.dev
copy .env.local
Database connection strings
npm install -g lerna yarn pm2
sudo pip install docker-compose
export NPM_TOKEN=00000000-0000-0000-000-00000000000
echo $NPM_TOKEN
lerna bootstrap
npm run dev

Cannot run application forever using PM2

When I am running the application using npm start I can able to run the application without any error.
I have installed pm2 to run node from now on.
I am using the command PM2 start npm start:
then I am using PM2 logs npm command I am able to see the application running in the terminal:
But when I'm running the browser nothing is running.
Nothing is also running when I'm running the browser.
Your npm start will most likely be a command with the node prefix, to run pm2 on a node project you'll have to NODE_ENV=<insert env> pm2 start node server.js and for react you'll have to pack/build your project and do pm2 start http-server -p <insert port>.
Other ways off running this forever is through nginx etc.
Hope this helps :-)

Why does `yarn install` hang when fetching packages on CentOS?

When attempting to install the dependencies for my project with Yarn via yarn install, the process (and progress bar indicator) hangs when attempting to fetch packages. A timeout never occurs and the --verbose option gives no useful clues regarding the cause of the problem.
CentOS 7
Yarn version: 0.27.5
This issue is caused by the combination of the older version of Git installed by Yum on CentOS (1.8.3.1-6 at the time of this writing) and Git's two-factor authentication mechanism.
Git's 2FA is the reason the hanging occurs in the first place, since one of the packages Yarn was attempting to fetch was a private repo via HTTPS (see here for details).
The version of the Git client in CentOS turned out to be the reason the hanging continued to occur and never timed / erred out. That is, the aforementioned version of Git on CentOS prevented Yarn from recognizing the authentication error and exiting accordingly.
The solution is to upgrade Git to a more recent version using a different repo:
sudo yum -y erase git
sudo rpm -U http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-2.noarch.rpm
sudo yum -y install git
This will stop Yarn from continuing to hang, with an output similar to the following:
[1/4] Resolving packages...
[2/4] Fetching packages...
error Command failed.
Exit code: 128
Command: git
...
fatal: could not read Username for 'https://github.com': terminal prompts disabled
My coworker and I had a similar issue and it was hanging because the vpn had disconnected. So double check your vpn is connected.

Incoming video issue in WebRTC

I'm trying first time to run video conference script WebRTC, the issue is that can't get the incoming video. You're can see http://wdd.co.il:1234
What I did:
1) Installed the node.js on debian 8 with commands that mentioned her:
apt-get install curl
curl --silent --location https://deb.nodesource.com/setup_0.12 | bash -
apt-get install --yes nodejs
apt-get install --yes build-essential
2) Installed following in the script folder:
npm install socket.io
npm install node-static
3) Run The server:
node server.js
After all that, nothing changed, steel not see the incoming video in client browser(firefix,chrome,opera).
I am almost certain that I'm missing something, asking for yours help to understand.
The files, server.js, index.html.

Categories