简体   繁体   English

在腻子会话超时后,Angular 会话被终止

[英]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我只想让 Angular 永远运行,直到我手动杀死它 所以我只是使用下面的命令在 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.它将使应用程序启动并运行并创建 nohup.out 文件,但只要腻子超时,会话就会消失。

Can anyone lead me to achieve this?谁能带领我实现这一目标?

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)你不应该在生产中使用 ng serve,你需要做的是构建你的 Angular 应用程序并在真实服务器(如 nginx 或 apache)中使用类似proxy_pass东西来告诉它为你的 Angular 静态应用程序文件(index.html)提供服务+ js 包)

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 !在服务器上运行带有ng serve的应用程序会冒很大的风险,因为它背后的 http 服务器不安全!

It can be good idea to use production ready tools like systemd to run your nodejs applicaiton - this manual can help:使用 systemd 等生产就绪工具来运行您的 nodejs 应用程序可能是个好主意 - 本手册可以提供帮助:

https://nodesource.com/blog/running-your-node-js-app-with-systemd-part-1/ 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在您的情况下,如果您的 ng 应用程序保存在/opt/app目录中,则单元文件将是这样的

[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在第二部分( https://nodesource.com/blog/running-your-node-js-app-with-systemd-part-2/ ),他们解释了如何启动几个应用程序实例并在他们面前使用 nginx作为具有 HTTPS 支持的负载平衡器和反向代理

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM