如何远程运行node.js

发布于 2024-11-01 10:35:09 字数 72 浏览 0 评论 0原文

我正在使用 putty 运行节点。但当 Putty 会话过期时它不起作用。如何永久启动节点js,如果putty会话结束则不应终止。

I am running node using putty. but it doesn't work when putty session expire. How can I start node js permanently, should not be terminated if putty session end.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

以为你会在 2024-11-08 10:35:09

我昨天刚刚使用 Forever > 解决了这个问题http://blog.nodejitsu.com/keep-a-nodejs -server-up-with-forever

太棒了。

  1. 安装:npm install Forver

  2. 运行:永远启动 yourServer.js

  3. 用于检查其是否正在运行:永远列表

酷吧?

I just solved that issue yesterday using Forever > http://blog.nodejitsu.com/keep-a-nodejs-server-up-with-forever

It's awesome.

  1. For Installing: npm install Forver

  2. For running: forever start yourServer.js

  3. For checking if its running: forever list

cool eh?

会傲 2024-11-08 10:35:09

通常,您使用守护程序来保持其运行。正确的答案取决于远程计算机运行的操作系统类型(Windows?)。

最好在 *unix 上运行 node.js。

Generally you use a deamon to keep it running. A proper answer depends on what type of OS your remote machine is running (windows ?).

It's best to run node.js on *unix.

感情洁癖 2024-11-08 10:35:09

Raynos 和 nEEbz 建议您还可以尝试使用 GNU Screen。这非常方便,特别是当您使用 putty 连接到远程服务器时。查看屏幕教程了解更多信息。

Among what Raynos and nEEbz are suggesting you can also try to use GNU Screen. This is very handy especially if you are using putty to connect to remote server. Check out this screen tutorial for more information.

抠脚大汉 2024-11-08 10:35:09

这是对“屏幕”的快速而温和的介绍。

在 ubuntu 中,如果您需要安装它,请使用: apt-get install screen

第一次使用:

$ screen

打印出一堆内容,然后另一个 shell 提示

$ node ./myapp.js

现在您的节点应用程序正在运行

您想要编辑其他一些代码?

control-a c

窗口将被清除,现在您将看到另一个 shell 提示符。节点仍在运行...

$ edit public/somewebfile.html

保存它,仍在编辑器中
返回节点

控制-a 控制-a

屏幕切换回运行节点的屏幕

需要离开办公室几分钟

control-a control-d
(screen detaches from your location... processes remain attached)
$ logout

屏幕断开连接,但是nodejs和编辑器仍在运行...

回到家...

> ssh work.some.where
> screen -D -R
screen reconnecting....

现在想连接工作吗再次查看 nodejs shell 屏幕,或者 control-a control-a 切换回该编辑器

control-a ?显示可用命令,或阅读不错的手册页:man screen

Here is a quick and gentle introduction to "screen" .

In ubuntu, if you need to install it, use: apt-get install screen

First use:

$ screen

bunch of stuff prints out, then another shell prompt

$ node ./myapp.js

now your node app is running

You want to edit some other code?

control-a c

the window clears, and you now have another shell prompt. node is still running....

$ edit public/somewebfile.html

save it, still in editor
go back to node

control-a control-a

screen switches back to the screen running node

need to leave the office for a few minutes

control-a control-d
(screen detaches from your location... processes remain attached)
$ logout

screen disconnects, but nodejs and the editor are still running...

back at home... want to connect to work

> ssh work.some.where
> screen -D -R
screen reconnecting....

now you see the nodejs shell screen again, or control-a control-a to switch back to that editor

control-a ? shows available commands, or read the nice man page: man screen

时光礼记 2024-11-08 10:35:09

您还可以运行 nohup:

nohup node app.js

You can also run nohup:

nohup node app.js
感情洁癖 2024-11-08 10:35:09

如果您在执行 npm install Forever 时遇到错误,请执行 npm install Forever -g

我遇到了这个问题。

https://www.npmjs.com/package/forever

If you get an error when you do npm install Forever, do npm install forever -g

I got that problem.

https://www.npmjs.com/package/forever

红尘作伴 2024-11-08 10:35:09

使用 PM2

只需在服务器上安装 pm2 并运行应用程序,如下所示:pm2 start app.js

您还可以从 Web 面板监控您的应用程序

PM2(进程管理器)

Use PM2

just install pm2 on the server and run app like this : pm2 start app.js

you can also monitor your application from the web panel

PM2 (proccess manager)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文