以编程方式监视并重新启动节点服务器 [英] Programmatically watch and restart node server

查看:30
本文介绍了以编程方式监视并重新启动节点服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次我想将更改推送到托管我的网站的服务器时,我都厌倦了使用 FileZilla,因此我设置了一个 github 存储库并将其链接到我的服务器,以便更改并直接推送到服务器.

I was getting tired of using FileZilla every time I wanted to push a change to my server hosting my website and so I set up a github repo and linked it to my server so that changes and pushed right to the server.

但是,我的后端是用 node 编写的,因此每次更新 server.js 文件时,我都必须重新启动服务器.使用节点 server.js"

However, my backend is written in node and so each time I update my server.js file I have to restart the server. With "node server.js"

有没有办法在检测到更新时监视文件并以编程方式重新启动节点服务器?

Is there a way to watch the file and programmatically restart the node server when an update is detected?

如果有帮助,我的服务器是运行 apache2 的 Ubuntu Linux

If it helps, my serve is Ubuntu Linux running apache2

推荐答案

您可以尝试自己编写一些东西,或者使用已经存在的流行库之一:

You could try writing something yourself, or use one of the popular libraries that are already out there:

这篇关于以编程方式监视并重新启动节点服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆