Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在azure中作为部署后操作挂钩运行node.js服务器_Azure_Kudu - Fatal编程技术网

在azure中作为部署后操作挂钩运行node.js服务器

在azure中作为部署后操作挂钩运行node.js服务器,azure,kudu,Azure,Kudu,我可以在azure中运行node.js服务器作为部署后操作挂钩吗? 详情如下: 命令是:npm运行测试:服务器 尝试在deploy.cmd(如下所示)中添加部署后操作,但在部署完成后忽略该操作(没有错误,部署成功) 以下是我的Jenkins控制台输出: remote: checking if package.json exists[K remote: Finished successfully.[K remote: Running post deployment command(s)...[K

我可以在azure中运行node.js服务器作为部署后操作挂钩吗?

详情如下:

命令是:
npm运行测试:服务器

尝试在deploy.cmd(如下所示)中添加部署后操作,但在部署完成后忽略该操作(没有错误,部署成功)

以下是我的Jenkins控制台输出:

remote: checking if package.json exists[K
remote: Finished successfully.[K
remote: Running post deployment command(s)...[K
remote: Deployment successful.[K
Notifying upstream projects of job completion
如果我使用调试控制台(如),看起来每次部署后都必须运行命令,而我更不希望这样做


可能是deploy.cmd配置不正确?

您是否尝试使用package.json中的
postinstall
脚本来运行该命令

例如,安装包后,可以使用以下命令运行
npm运行测试:servers

"scripts": {
    "postinstall": "npm run test:servers"
}

尽管我们几乎在任何地方都是这样做的,
package.json
,但是Azure不尊重许多
package.json
操作,所以我不选择这些操作

你肯定是在正确的轨道上。我自己在这方面取得了成功,以下是我所做的:

下面是我的
deploy.cmd
中的确切代码,我是在
goto end
之前添加的:

IF EXIST "%DEPLOYMENT_TARGET%\publish.js" (
  pushd "%DEPLOYMENT_TARGET%"
  node "%DEPLOYMENT_TARGET%\publish.js"
  IF !ERRORLEVEL! NEQ 0 goto error
  popd
)
publish.js
中执行您想要的任何操作。在我的例子中,我进行HTTP和Redis调用。在我的测试中,我在Redis中设置了一个键,这样我就知道它是被调用的,而不是被跳过的。所以,你可以做任何事。你只需要做你需要做的事情


唯一需要注意的是:对于我的场景,它有时似乎会挂起一点,但最终会继续运行服务器,但部署挂起(并最终失败),因为服务器一直在运行-它们永远不会完成(不像大多数其他运行到完成的脚本)
IF EXIST "%DEPLOYMENT_TARGET%\publish.js" (
  pushd "%DEPLOYMENT_TARGET%"
  node "%DEPLOYMENT_TARGET%\publish.js"
  IF !ERRORLEVEL! NEQ 0 goto error
  popd
)