【问题标题】:deployment problem with permission denied while selecting node version选择节点版本时权限被拒绝的部署问题
【发布时间】:2020-12-21 23:11:00
【问题描述】:

从一开始,我就一直在为我的 node 12 Web 应用程序使用 kudu 部署时遇到问题。 这次我在管道日志中有select node version failed,但是当我从链接访问日志详细信息时是Not setting execute permissions for bash。最糟糕的是代码或管道中没有任何变化,有一天你醒来,你的应用程序不再工作了。这是第三次发生,每次在可用版本列表中都有可用的新版本节点时。有人可以指出可以使用超过一个月的解决方案吗?我使用了 kudu 文档中节点 Web 应用程序的默认脚本,只是将 npm 替换为 yarn。并在应用配置中使用环境变量WEBSITE_NODE_DEFAULT_VERSIONWEBSITE_NPM_DEFAULT_VERSION。我尝试了带有或不带有 npm 的节点版本 var 的每种组合,......没有任何效果。我真的需要一个长期的解决方案来最终解决这个问题,否则我想我会转向更稳定的替代方案。任何帮助深表感谢。 一个可以相关的问题https://github.com/projectkudu/kudu/issues/2870#issuecomment-443464291

编辑

这是我的 .deployment 文件

[config]
command = bash ./scripts/bash/deploy.sh

这是我在scripts/bash/deploy.sh 中的shell 文件,您可以看到与使用命令kuduscript -y --node 检索的默认自定义部署脚本的唯一区别是yarn 而不是npm

#!/bin/bash

# ----------------------
# KUDU Deployment Script
# Version: 1.0.17
# ----------------------

# Helpers
# -------

exitWithMessageOnError() {
  if [ ! $? -eq 0 ]; then
    echo "An error has occurred during web site deployment."
    echo $1
    exit 1
  fi
}

# Prerequisites
# -------------

# Verify node.js installed
hash node 2>/dev/null
exitWithMessageOnError "Missing node.js executable, please install node.js, if already installed make sure it can be reached from current environment."

# Setup
# -----

SCRIPT_DIR="${BASH_SOURCE[0]%\\*}"
SCRIPT_DIR="${SCRIPT_DIR%/*}"
ARTIFACTS=$SCRIPT_DIR/../artifacts
KUDU_SYNC_CMD=${KUDU_SYNC_CMD//\"/}

if [[ ! -n "$DEPLOYMENT_SOURCE" ]]; then
  DEPLOYMENT_SOURCE=$SCRIPT_DIR
fi

if [[ ! -n "$NEXT_MANIFEST_PATH" ]]; then
  NEXT_MANIFEST_PATH=$ARTIFACTS/manifest

  if [[ ! -n "$PREVIOUS_MANIFEST_PATH" ]]; then
    PREVIOUS_MANIFEST_PATH=$NEXT_MANIFEST_PATH
  fi
fi

if [[ ! -n "$DEPLOYMENT_TARGET" ]]; then
  DEPLOYMENT_TARGET=$ARTIFACTS/wwwroot
else
  KUDU_SERVICE=true
fi

if [[ ! -n "$KUDU_SYNC_CMD" ]]; then
  # Install kudu sync
  echo Installing Kudu Sync
  npm install kudusync -g --silent
  exitWithMessageOnError "npm failed"

  if [[ ! -n "$KUDU_SERVICE" ]]; then
    # In case we are running locally this is the correct location of kuduSync
    KUDU_SYNC_CMD=kuduSync
  else
    # In case we are running on kudu service this is the correct location of kuduSync
    KUDU_SYNC_CMD=$APPDATA/npm/node_modules/kuduSync/bin/kuduSync
  fi
fi

# Node Helpers
# ------------

selectNodeVersion() {
  if [[ -n "$KUDU_SELECT_NODE_VERSION_CMD" ]]; then
    SELECT_NODE_VERSION="$KUDU_SELECT_NODE_VERSION_CMD \"$DEPLOYMENT_SOURCE\" \"$DEPLOYMENT_TARGET\" \"$DEPLOYMENT_TEMP\""
    eval $SELECT_NODE_VERSION
    exitWithMessageOnError "select node version failed"

    if [[ -e "$DEPLOYMENT_TEMP/__nodeVersion.tmp" ]]; then
      NODE_EXE=$(cat "$DEPLOYMENT_TEMP/__nodeVersion.tmp")
      exitWithMessageOnError "getting node version failed"
    fi

    if [[ -e "$DEPLOYMENT_TEMP/__npmVersion.tmp" ]]; then
      NPM_JS_PATH=$(cat "$DEPLOYMENT_TEMP/__npmVersion.tmp")
      exitWithMessageOnError "getting npm version failed"
    fi

    if [[ ! -n "$NODE_EXE" ]]; then
      NODE_EXE=node
    fi

    NPM_CMD="\"$NODE_EXE\" \"$NPM_JS_PATH\""
  else
    NPM_CMD=npm
    NODE_EXE=node
  fi
}

##################################################################################################################################
# Deployment
# ----------

echo Handling node.js deployment.

# 1. KuduSync
if [[ "$IN_PLACE_DEPLOYMENT" -ne "1" ]]; then
  "$KUDU_SYNC_CMD" -v 50 -f "$DEPLOYMENT_SOURCE" -t "$DEPLOYMENT_TARGET" -n "$NEXT_MANIFEST_PATH" -p "$PREVIOUS_MANIFEST_PATH" -i ".git;.hg;.deployment;deploy.sh"
  exitWithMessageOnError "Kudu Sync failed"
fi

# 2. Select node version
selectNodeVersion

# 3. Install yarn packages
if [ -e "$DEPLOYMENT_TARGET/package.json" ]; then
  cd "$DEPLOYMENT_TARGET"
  echo "Running yarn install"
  eval yarn install --production=false --network-timeout 1000000
  echo "building dist"
  eval yarn build
  echo "Running migrations"
  eval yarn typeorm:migration:run
  exitWithMessageOnError "yarn failed"
  cd - >/dev/null
fi

##################################################################################################################################
echo "Finished successfully."

我只将变量WEBSITE_NODE_DEFAULT_VERSION 设置为12.18.2(这一次,但我已经尝试了多种组合),而我没有设置WEBSITE_NPM_DEFAULT_VERSION 变量。这是我尝试使用 git local 方法部署时的输出,使用命令git push azure master:master:

Enumerating objects: 9, done.
Counting objects: 100% (9/9), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (5/5), 391 bytes | 391.00 KiB/s, done.
Total 5 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Deploy Async
remote: Updating branch 'master'.
remote: Updating submodules.
remote: Preparing deployment for commit id '79f0842a60'.
remote: Running custom deployment command...
remote: Not setting execute permissions for bash ./scripts/bash/deploy.sh
remote: Running deployment command...
remote: Handling node.js deployment.
remote: Kudu sync from: '/home/site/repository' to: '/home/site/wwwroot'
remote: Ignoring: .deployment
remote: Ignoring: .git
remote: Ignoring: scripts/bash/deploy.sh
remote: Detecting node version spec...
remote: Using appsetting WEBSITE_NODE_DEFAULT_VERSION value: 12.18.2
remote: Node.js versions available on the platform are: 8.0.0, 8.1.4, 8.2.1, 8.8.1, 8.9.4, 8.11.4, 8.12.0, 8.15.1, 8.17.0, 9.4.0, 10.1.0, 10.10.0, 10.14.2, 10.21.0, 10.23.0, 12.18.2, 12.19.0, 14.15.0.
remote: ENOENT: no such file or directory, open '/opt/nodejs/12.18.2/npm.txt'
remote: Resolved to version 12.18.2
remote: Detecting npm version spec...
remote: An error has occurred during web site deployment.
remote: select node version failed
remote: Deployment Logs : 'https://***.scm.azurewebsites.net/newui/jsonviewer?view_url=/api/deployments/79f0842a60c7fe25af603fe673868789272923e3/log'
To https://***.scm.azurewebsites.net:443/kiwi-prod-appservice.git
   cdc1c91..79f0842  master -> master

当我点击链接查看日志详情时:

[
    "0" :
    {
        "details_url" : null,
        "id" : "660d4119-1437-494a-a97b-5af7244afd58",
        "log_time" : "2020-12-22T04:58:51.7786621Z",
        "message" : "Updating branch 'master'.",
        "type" : 0
    }
    ,
    "1" :
    {
        "details_url" : null,
        "id" : "bca90e55-fc4c-40c4-91bd-337a0e3df515",
        "log_time" : "2020-12-22T04:58:53.3322101Z",
        "message" : "Updating submodules.",
        "type" : 0
    }
    ,
    "2" :
    {
        "details_url" : null,
        "id" : "bfc59c6f-e3ad-4bbd-afb5-bda11bec9771",
        "log_time" : "2020-12-22T04:58:53.3779506Z",
        "message" : "Preparing deployment for commit id '79f0842a60'.",
        "type" : 0
    }
    ,
    "3" :
    {
        "details_url" : null,
        "id" : "92219cc6-d58f-4988-9ec5-c1fd109c0986",
        "log_time" : "2020-12-22T04:58:53.4866308Z",
        "message" : "Running custom deployment command...",
        "type" : 0
    }
    ,
    "4" :
    {
        "details_url" : null,
        "id" : "f61aa2f5-8d77-4d3b-b328-3ab1fc69bf33",
        "log_time" : "2020-12-22T04:58:53.51928Z",
        "message" : "Not setting execute permissions for bash ./scripts/bash/deploy.sh",
        "type" : 0
    }
    ,
    "5" :
    {
        "details_url" : "https://***.scm.azurewebsites.net/api/deployments/79f0842a60c7fe25af603fe673868789272923e3/log/3ed28b72-4514-4c87-8d6a-006c09150754",
        "id" : "3ed28b72-4514-4c87-8d6a-006c09150754",
        "log_time" : "2020-12-22T04:58:53.5555321Z",
        "message" : "Running deployment command...",
        "type" : 2
    }
]

【问题讨论】:

  • 我们无法重现您描述的现象。你可以告诉我们你做了什么以及如何重现问题。详细告诉我们这些步骤,以便您更好地解决问题。或者直接提出支持票寻求帮助,微软工程师会帮你查日志。
  • @JasonPan 我编辑了帖子并放置了所有细节。提前谢谢你
  • 另外,从 kudu 调试 bash 控制台,当我输入 node -v 时,我得到 v14.15.0。这是基于 linux 的容器的唯一版本吗?
  • 尝试在新创建的插槽上部署时出现同样的错误

标签: azure-web-app-service kudu


【解决方案1】:

在评论SELECT_NODE_VERSION 命令后解决(暂时)

# SELECT_NODE_VERSION="$KUDU_SELECT_NODE_VERSION_CMD \"$DEPLOYMENT_SOURCE\" \"$DEPLOYMENT_TARGET\" \"$DEPLOYMENT_TEMP\""
# eval $SELECT_NODE_VERSION
# exitWithMessageOnError "select node version failed"

因为错误总是被触发。我还不得不使用npm 而不是yarn,因为yarn 使用的节点版本不是正确的

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-01-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-16
    • 2012-06-14
    • 2013-02-09
    相关资源
    最近更新 更多