ArrchanaMohan
ArrchanaMohan

Reputation: 2566

The Angular session is killed after the putty session timeout

I just want to run the Angular to run forever until I kill it manual So I just used the below command to run it as service in linux box

 nohup ng serve --host {xyz.com} &

It will make the application Up and running and created nohup.out file but the session is gone as soon as the putty is time out.

Can anyone lead me to achieve this?

Upvotes: 0

Views: 559

Answers (2)

Mehdi Benmoha
Mehdi Benmoha

Reputation: 3935

You shouldn't be using ng serve in production, what you need to do is build your Angular App and use something like proxy_pass in a real server (like nginx or apache) to tell it to serve your Angular static app files (index.html + js bundles)

You are taking a big risk by running the app with ng serve on a server as the http server behind it is not secure !

Upvotes: 1

vodolaz095
vodolaz095

Reputation: 6986

It can be good idea to use production ready tools like systemd to run your nodejs applicaiton - this manual can help:

https://nodesource.com/blog/running-your-node-js-app-with-systemd-part-1/

In your case, if your ng app is saved in /opt/app directory, unit file will be something like this

[Unit]
Description=hello_env.js - making your environment variables rad
Documentation=https://example.com
After=network.target

[Service]
Environment=NODE_PORT=3001
Type=simple
User=ubuntu

Workdir=/opt/app
ExecStart=/usr/bin/node /opt/app/.bin/ng serve --host {xyz.com}

Restart=on-failure

[Install]
WantedBy=multi-user.target

in 2nd part (https://nodesource.com/blog/running-your-node-js-app-with-systemd-part-2/), they explained how to start few instances of application and use nginx in front of them as load balancer and reverse proxy with HTTPS support

Upvotes: 0

Related Questions