帮助理解 运行-command 中的 bashing 脚本
Helping understanding bashing scripting in run-command
我继承了一些我试图理解的代码。它是 azure cli 命令和 linux bash 脚本
的组合
#!/bin/bash -e
info "Installing Dependencies"
declare -a PIDS=()
# "Deploying into the VMs"
for i in $(seq 1 $NODES_NUM); do
THIS_VM_NAME="${VM_NAME}${i}"
# "Check if the VM exists"
if `az vm list -o table | grep -q "${THIS_VM_NAME}"`; then
info "Deploying: Installing deps and Pairty, Executing for ${THIS_VM_NAME}"
PIDS[${i}]=$!
az vm run-command invoke --name ${THIS_VM_NAME} \
--command-id RunShellScript \
--resource-group ${RSC_GRP_NAME} \
--query "output[].message | join('\n\n', @)" \
--scripts @${TEMPLATES}/user-data.sh &
PIDS[${i}]=$!
fi
done
# wait for all pids
info "Waiting for Completion.."
for pid in ${PIDS[*]}; do
wait $pid
done
我想感谢指针了解如何
@${TEMPLATES}/user-data.sh &
PIDS[${i}]=$!
有效。
- 我看不到变量被导入到脚本中
- 该文件位于另一个文件夹中,它奇迹般地起作用了?
- 我也很感激关于
PIDS
的指示,这是否意味着进程可以 运行 并发?
通过测试,同样的事情发生在我身上。但两周前效果很好。我会告诉你一些东西:
最后
命令和输出都正常。在后端,脚本应该像上面那样。
现在
可以看到命令没有在后台设置参数。但是如果你只是 运行 带有参数的 shell 命令它也能正常工作。
根据测试,可能这几天CLI出了什么不好的事情。您可以等待连续几天,然后再次 运行 CLI 命令。
The file is located in another folders, and it micraculously works?
如果您指的是另一个文件夹中的 shell 脚本,如果 CLI 命令照常工作,它也能正常工作。
I would also appreciate pointers on the PIDS does it mean that
processes can run concurrently?
有一点你要注意。 CLI 命令 运行s 作为 Linux 中的一个进程,因此它可以 运行 同时在后端运行。但是 run-command
只是 运行 通过具有 VM 的代理发送 shell 脚本,并且它一次只是 运行 一个脚本。您可以获取详细信息 here.
此外,你可以使用VM扩展通过运行命令来做你想做的事情,它更可用。
希望对您有所帮助。
我继承了一些我试图理解的代码。它是 azure cli 命令和 linux bash 脚本
的组合#!/bin/bash -e
info "Installing Dependencies"
declare -a PIDS=()
# "Deploying into the VMs"
for i in $(seq 1 $NODES_NUM); do
THIS_VM_NAME="${VM_NAME}${i}"
# "Check if the VM exists"
if `az vm list -o table | grep -q "${THIS_VM_NAME}"`; then
info "Deploying: Installing deps and Pairty, Executing for ${THIS_VM_NAME}"
PIDS[${i}]=$!
az vm run-command invoke --name ${THIS_VM_NAME} \
--command-id RunShellScript \
--resource-group ${RSC_GRP_NAME} \
--query "output[].message | join('\n\n', @)" \
--scripts @${TEMPLATES}/user-data.sh &
PIDS[${i}]=$!
fi
done
# wait for all pids
info "Waiting for Completion.."
for pid in ${PIDS[*]}; do
wait $pid
done
我想感谢指针了解如何
@${TEMPLATES}/user-data.sh &
PIDS[${i}]=$!
有效。
- 我看不到变量被导入到脚本中
- 该文件位于另一个文件夹中,它奇迹般地起作用了?
- 我也很感激关于
PIDS
的指示,这是否意味着进程可以 运行 并发?
通过测试,同样的事情发生在我身上。但两周前效果很好。我会告诉你一些东西:
最后
命令和输出都正常。在后端,脚本应该像上面那样。
现在
可以看到命令没有在后台设置参数。但是如果你只是 运行 带有参数的 shell 命令它也能正常工作。
根据测试,可能这几天CLI出了什么不好的事情。您可以等待连续几天,然后再次 运行 CLI 命令。
The file is located in another folders, and it micraculously works?
如果您指的是另一个文件夹中的 shell 脚本,如果 CLI 命令照常工作,它也能正常工作。
I would also appreciate pointers on the PIDS does it mean that processes can run concurrently?
有一点你要注意。 CLI 命令 运行s 作为 Linux 中的一个进程,因此它可以 运行 同时在后端运行。但是 run-command
只是 运行 通过具有 VM 的代理发送 shell 脚本,并且它一次只是 运行 一个脚本。您可以获取详细信息 here.
此外,你可以使用VM扩展通过运行命令来做你想做的事情,它更可用。
希望对您有所帮助。