远程执行node.js脚本

时间:2016-03-08 05:23:28

标签: node.js powershell jenkins deployment

我正在使用Jenkins服务器为我的Node.js应用程序设置持续集成。对于部署,我使用的是powershell脚本,为此我安装了powershell插件。该脚本需要按顺序执行以下任务。

# Step1
# Stop all the currently running services on web server. For that I am trying to
# execute maintenance.js remotely from the build server under node
node \\SharedWebServerFolder\Utilities\maintenance.js stopServices

# Step2
# Copies all the resources to server at \\SharedServerWebFolder

# Step3
# Start the services
node \\SharedWebServerFolder\Utilities\maintenance.js startServices

执行Step2没问题。我的问题是关于Step1和Step3。

  1. 我应该从构建服务器远程执行maintenance.js吗?这甚至可能吗? (假设我在构建服务器上安装了node.js)

  2. 我是否应该在本地执行maintenance.js的Web服务器上再添加一个PowerShell脚本?因此,基本上部署脚本(来自构建服务器)将执行远程PowerShell脚本(位于Web服务器上),远程PowerShell脚本将在本地执行maintenance.js。在这种情况下,我不必在构建服务器上安装Node.js.

  3. 建议什么?

2 个答案:

答案 0 :(得分:0)

人们通常使用ssh远程执行命令。我想你想从你的生产/登台服务器上的构建服务器执行一个命令。

请参阅linux execute command remotely

这很简单,远程盒子是一个linux盒子。

如果您的遥控器是Windows机器,那么您仍然可以在其上运行ssh服务器,但设置起来更加痛苦。你可以试试Bitvise SSH Client。

正确设置ssh客户端后,您应该能够从构建服务器执行远程命令。

答案 1 :(得分:0)

我已经使用Jenkins SSH插件在我的远程登台/生产服务器中进行部署。我建议在Web服务器计算机而不是构建服务器中执行'maintenance.js'。您只需触发'maintenance.js'执行使用ssh从构建服务器升级/生产服务器。我相信很难从构建服务器远程执行'maintenance.js'。

相关问题