您好 @WesPenre ![]()
错误应该比您截图显示的要靠前。您能否在此处粘贴完整的日志,以便大家看到可能存在的问题?
您好 @WesPenre ![]()
错误应该比您截图显示的要靠前。您能否在此处粘贴完整的日志,以便大家看到可能存在的问题?
如果我无法登录 Discourse,有人能告诉我如何创建错误日志吗?我可以在 WinSCP 中找到它吗?如果可以,日志的目录和名称是什么?
就是这样吗?这是启动器文件:
#!/usr/bin/env bash
usage () {
echo "用法:launcher 命令 配置 [--skip-prereqs] [--docker-args 字符串]"
echo "命令:"
echo " start: 启动/初始化容器"
echo " stop: 停止正在运行的容器"
echo " restart: 重启容器"
echo " destroy: 停止并删除容器"
echo " enter: 打开 Shell 以在容器内运行命令"
echo " logs: 查看容器的 Docker 日志"
echo " bootstrap: 基于模板为配置引导容器"
echo " run: 在上一次引导的镜像上下文中,使用配置运行给定命令"
echo " rebuild: 重建容器(销毁旧容器、引导、启动新容器)"
echo " cleanup: 删除所有已停止超过 24 小时的容器"
echo " start-cmd: 生成用于启动容器的 Docker 命令"
echo
echo "选项:"
echo " --skip-prereqs 不检查启动器前置条件"
echo " --docker-args 运行 Docker 时传递的额外参数"
echo " --skip-mac-address 不分配 MAC 地址"
echo " --run-image 覆盖用于运行容器的镜像"
exit 1
}
# 供后续可能重新执行使用
SAVED_ARGV=("$@")
command=$1
config=$2
# user_args_argv 在解析参数向量时分配一次。
user_args_argv=""
# user_args 是可变的:其值在解析模板时可能会改变。
# 是 user_args_argv 的超集。
user_args=""
user_run_image=""
if [[ $command == "run" ]]; then
run_command=$3
fi
while [ ${#} -gt 0 ]; do
case "${1}" in
--debug)
DEBUG="1"
;;
--skip-prereqs)
SKIP_PREREQS="1"
;;
--skip-mac-address)
SKIP_MAC_ADDRESS="1"
;;
--docker-args)
user_args_argv="$2"
user_args="$user_args_argv"
shift
;;
--run-image)
user_run_image="$2"
shift
;;
esac
shift 1
done
if [ -z "$command" -o -z "$config" -a "$command" != "cleanup" ]; then
usage
fi
# Docker 不喜欢大写字母、空格或特殊字符,在构建所有内容之前先捕获错误,以免之后才发现
re='[[:upper:]/ !@#$%^&*()+~`=]'
if [[ $config =~ $re ]];
then
echo
echo "错误:配置名称 '$config' 不得包含大写字母、空格或特殊字符。请修正配置名称并重新运行 $0。"
echo
exit 1
fi
cd "$(dirname "$0")"
pups_version='v1.0.3'
docker_min_version='17.03.1'
docker_rec_version='17.06.2'
git_min_version='1.8.0'
git_rec_version='1.8.0'
kernel_min_version='4.4.0'
config_file=containers/"$config".yml
cidbootstrap=cids/"$config"_bootstrap.cid
local_discourse=local_discourse
image="discourse/base:2.0.20230217-0055"
image_stable="discourse/base:2.0.20230116-0051"
docker_path=`which docker.io 2> /dev/null || which docker`
git_path=`which git`
if [ "${SUPERVISED}" = "true" ]; then
restart_policy="--restart=no"
attach_on_start="-a"
attach_on_run="-a stdout -a stderr"
else
attach_on_run="-d"
fi
if [ -n "$DOCKER_HOST" ]; then
docker_ip=`sed -e 's/^tcp:\/\/\(.*\):.*$/\1/' <<< "$DOCKER_HOST"`
elif [ -x "$(which ip 2>/dev/null)" ]; then
docker_ip=`ip addr show docker0 | \
grep 'inet ' | \
awk '{ split($2,a,"/"); print a[1] }';`
else
docker_ip=`ifconfig | \
grep -B1 "inet addr" | \
awk '{ if ( $1 == "inet" ) { print $2 } else if ( $2 == "Link" ) { printf "%s:" ,$1 } }' | \
grep docker0 | \
awk -F: '{ print $3 }';`
fi
# 来自 https://stackoverflow.com/a/44660519/702738
compare_version() {
if [[ $1 == $2 ]]; then
return 1
fi
local IFS=.
local i a=(${1%%[^0-9.]*}) b=(${2%%[^0-9.]*})
local arem=${1#${1%%[^0-9.]*}} brem=${2#${2%%[^0-9.]*}}
for ((i=0; i<${#a[@]} || i<${#b[@]}; i++)); do
if ((10#${a[i]:-0} < 10#${b[i]:-0})); then
return 1
elif ((10#${a[i]:-0} > 10#${b[i]:-0})); then
return 0
fi
done
if [ "$arem" '<' "$brem" ]; then
return 1
elif [ "$arem" '>' "$brem" ]; then
return 0
fi
return 1
}
fatal () {
echo -e "\n$1\n"
exit "${2:-1}"
}
install_docker() {
echo "未安装 Docker,您需要安装 Docker 才能运行启动器"
echo "参见 https://docs.docker.com/installation/"
exit 1
}
pull_image() {
# 添加一次重试以解决 dockerhub TLS 错误
$docker_path pull $image || $docker_path pull $image
}
check_prereqs() {
if [ -z $docker_path ]; then
install_docker
fi
# 1. Docker 守护进程是否正在运行?
# 我们将 stderr 发送到 /dev/null,因为我们不关心警告,
# 它通常会抱怨交换空间,但这无关紧要
test=`$docker_path info 2> /dev/null`
if [[ $? -ne 0 ]] ; then
echo "无法连接到 Docker 守护进程 - 请确认它正在运行且您有访问权限"
exit 1
fi
# 2. 是否运行已批准的存储驱动程序?
if ! $docker_path info 2> /dev/null | egrep -q 'Storage Driver: (btrfs|aufs|zfs|overlay2)$'; then
echo "您的 Docker 安装未使用支持的存储驱动程序。如果我们继续,可能会导致安装损坏。"
echo "overlay2 是推荐的存储驱动程序,尽管 zfs 和 aufs 也可能有效。"
echo "其他存储驱动程序已知存在问题。"
echo "您可以通过运行 \"docker info\" 并查看 'Storage Driver' 行来了解您正在使用的文件系统。"
echo
echo "如果您希望继续使用现有的不受支持的存储驱动程序,"
echo "请阅读启动器的源代码,找出如何绕过此检查。"
exit 1
fi
# 3. 是否运行推荐的 Docker 版本
test=($($docker_path --version)) # 获取 Docker 版本字符串
test=${test[2]//,/} # 仅获取版本号并去除逗号(如果存在)
# 至少满足最低 Docker 版本
if compare_version "${docker_min_version}" "${test}"; then
echo "错误:不支持 Docker 版本 ${test},请升级到至少 ${docker_min_version},推荐版本为 ${docker_rec_version}"
exit 1
fi
# 推荐更新的 Docker 版本
if compare_version "${docker_rec_version}" "${test}"; then
echo "警告:Docker 版本 ${test} 已弃用,建议升级到 ${docker_rec_version} 或更高版本。"
fi
arm=false
case $(uname -m) in
armv7l)
echo "错误:不支持 32 位 ARM。请检查您的硬件是否支持 arm64,目前 arm64 处于实验性支持状态。"
exit 1
;;
aarch64 | arm64)
echo "警告:目前 aarch64 的支持处于实验阶段。请在 https://meta.discourse.org/tag/arm 报告任何问题"
image="discourse/base:aarch64"
arm=true
;;
x86_64)
echo "检测到 x86_64 架构。"
;;
*)
echo "错误:检测到未知架构。"
exit 1
;;
esac
# 4. Discourse Docker 镜像是否已下载
test=`$docker_path images | awk '{print $1 ":" $2 }' | grep "$image"`
# arm 实验性支持使用固定标签,始终拉取
if [ -z "$test" ] || [ $arm = true ]; then
echo
echo "警告:我们将开始下载 Discourse 基础镜像"
echo "此过程可能需要几分钟到一小时,具体取决于您的网络速度"
echo
echo "请耐心等待"
echo
pull_image
fi
# 为稳定版使用较旧的镜像
version=$(cat $config_file | $docker_path run $user_args --rm -i -a stdout -a stdin $image ruby -e \
"require 'yaml'; puts YAML.load(STDIN.readlines.join)['params']['version']")
if [ "$version" = "stable" ]; then
image=$image_stable
pull_image
fi
# 5. 是否运行推荐的 Git 版本
test=($($git_path --version)) # 获取 Git 版本字符串
test=${test[2]//,/} # 仅获取版本号并去除逗号(如果存在)
# 至少满足最低版本
if compare_version "${git_min_version}" "${test}"; then
echo "错误:不支持 Git 版本 ${test},请升级到至少 ${git_min_version},推荐版本为 ${git_rec_version}"
exit 1
fi
# 推荐最佳版本
if compare_version "${git_rec_version}" "${test}"; then
echo "警告:Git 版本 ${test} 已弃用,建议升级到 ${git_rec_version} 或更高版本。"
fi
# 检查最低内核版本,参考 https://bugs.ruby-lang.org/issues/13885
test=($(uname -r))
# 至少满足最低版本
if compare_version "${kernel_min_version}" "${test}"; then
echo "错误:不支持内核版本 ${test},请升级到至少 ${kernel_min_version}"
exit 1
fi
# 6. 是否能够附加 stderr / stdout / tty
test=`$docker_path run $user_args -i --rm -a stdout -a stderr $image echo working`
if [[ "$test" =~ "working" ]] ; then : ; else
echo "您的 Docker 安装无法正常工作"
echo
echo "参见:https://meta.discourse.org/t/docker-error-on-bootstrap/13657/18?u=sam"
exit 1
fi
# 7. Docker 文件夹是否有足够的空间进行引导
folder=`$docker_path info --format '{{.DockerRootDir}}'`
safe_folder=${folder:-/var/lib/docker}
if [[ -d $safe_folder && $(stat -f --format="%a*%S" $safe_folder)/1024**3 -lt 5 ]] ; then
echo "在 $safe_folder 所在的磁盘上可用空间少于 5GB。您需要更多空间才能继续"
df -h $safe_folder
echo
if tty >/dev/null; then
read -p "您是否希望通过清理系统中的 Docker 镜像和容器来尝试回收空间?(y/N)" -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
$docker_path container prune --force --filter until=24h >/dev/null
$docker_path image prune --all --force --filter until=24h >/dev/null
echo "如果清理成功,您现在可以尝试再次运行"
fi
fi
exit 1
fi
# 8. 容器定义文件是否可访问且不安全(世界可读)
if [[ ! -e "$config_file" || ! -r "$config_file" ]]; then
echo "错误:$config_file 不存在或不可读。"
echo
echo "可用配置( `cd containers && ls -dm *.yml | tr -s '\n' ' ' | awk '{ gsub(/\.yml/, ""); print }'`)"
exit 1
elif [[ "$(find $config_file -perm -004)" ]]; then
echo "警告:$config_file 文件对所有用户可读。您可以通过运行以下命令来保护此文件:chmod o-rwx $config_file"
fi
}
if [ -z "$SKIP_PREREQS" ] && [ "$command" != "cleanup" ]; then
check_prereqs
fi
set_volumes() {
volumes=`cat $config_file | $docker_path run $user_args --rm -i -a stdout -a stdin $image ruby -e \
"require 'yaml'; puts YAML.load(STDIN.readlines.join)['volumes'].map{|v| '-v ' << v['volume']['host'] << ':' << v['volume']['guest'] << ' '}.join"`
}
set_links() {
links=`cat $config_file | $docker_path run $user_args --rm -i -a stdout -a stdin $image ruby -e \
"require 'yaml'; puts YAML.load(STDIN.readlines.join)['links'].map{|l| '--link ' << l['link']['name'] << ':' << l['link']['alias'] << ' '}.join"`
}
find_templates() {
local templates=`cat $1 | $docker_path run $user_args --rm -i -a stdin -a stdout $image ruby -e \
"require 'yaml'; puts YAML.load(STDIN.readlines.join)['templates']"`
local arrTemplates=${templates// / }
if [ ! -z "$templates" ]; then
echo $templates
else
echo ""
fi
}
set_template_info() {
templates=$(find_templates $config_file)
arrTemplates=(${templates// / })
config_data=$(cat $config_file)
input="hack: true"
for template in "${arrTemplates[@]}"
do
[ ! -z $template ] && {
input="$input _FILE_SEPERATOR_ $(cat $template)"
}
done
# 我们总是希望配置文件在最后,以便它具有优先级
input="$input _FILE_SEPERATOR_ $config_data"
read -r -d '' env_ruby << 'RUBY'
require 'yaml'
input=STDIN.readlines.join
# 出于数据库的考虑,默认使用 UTF-8
env = {'LANG' => 'en_US.UTF-8'}
input.split('_FILE_SEPERATOR_').each do |yml|
yml.strip!
begin
env.merge!(YAML.load(yml)['env'] || {})
rescue Psych::SyntaxError => e
puts e
puts "*错误。"
rescue => e
puts yml
p e
end
end
env.each{|k,v| puts "*错误。" if v.is_a?(Hash)}
puts env.map{|k,v| "-e\n#{k}=#{v}" }.join("\n")
RUBY
tmp_input_file=$(mktemp)
echo "$input" > "$tmp_input_file"
raw=`exec cat "$tmp_input_file" | $docker_path run $user_args --rm -i -a stdin -a stdout $image ruby -e "$env_ruby"`
rm -f "$tmp_input_file"
env=()
ok=1
while read i; do
if [ "$i" == "*错误。" ]; then
ok=0
elif [ -n "$i" ]; then
env[${#env[@]}]="${i//\{\{config\}\}/${config}}"
fi
done <<< "$raw"
if [ "$ok" -ne 1 ]; then
echo "${env[@]}"
echo "YAML 语法错误。请检查您的 containers/*.yml 配置文件。"
exit 1
fi
# 标签
read -r -d '' labels_ruby << 'RUBY'
require 'yaml'
input=STDIN.readlines.join
labels = {}
input.split('_FILE_SEPERATOR_').each do |yml|
yml.strip!
begin
labels.merge!(YAML.load(yml)['labels'] || {})
rescue Psych::SyntaxError => e
puts e
puts "*错误。"
rescue => e
puts yml
p e
end
end
puts labels.map{|k,v| "-l\n#{k}=#{v}" }.join("\n")
RUBY
tmp_input_file=$(mktemp)
echo "$input" > "$tmp_input_file"
raw=`exec cat "$tmp_input_file" | $docker_path run $user_args --rm -i -a stdin -a stdout $image ruby -e "$labels_ruby"`
rm -f "$tmp_input_file"
labels=()
ok=1
while read i; do
if [ "$i" == "*错误。" ]; then
ok=0
elif [ -n "$i" ]; then
labels[${#labels[@]}]=$(echo $i | sed s/{{config}}/${config}/g)
fi
done <<< "$raw"
if [ "$ok" -ne 1 ]; then
echo "${labels[@]}"
echo "YAML 语法错误。请检查您的 containers/*.yml 配置文件。"
exit 1
fi
# 暴露端口
read -r -d '' ports_ruby << 'RUBY'
require 'yaml'
input=STDIN.readlines.join
ports = []
input.split('_FILE_SEPERATOR_').each do |yml|
yml.strip!
begin
ports += (YAML.load(yml)['expose'] || [])
rescue Psych::SyntaxError => e
puts e
puts "*错误。"
rescue => e
puts yml
p e
end
end
puts ports.map { |p| p.to_s.include?(':') ? "-p\n#{p}" : "--expose\n#{p}" }.join("\n")
RUBY
tmp_input_file=$(mktemp)
echo "$input" > "$tmp_input_file"
raw=`exec cat "$tmp_input_file" | $docker_path run $user_args --rm -i -a stdin -a stdout $image ruby -e "$ports_ruby"`
rm -f "$tmp_input_file"
ports=()
ok=1
while read i; do
if [ "$i" == "*错误。" ]; then
ok=0
elif [ -n "$i" ]; then
ports[${#ports[@]}]=$i
fi
done <<< "$raw"
if [ "$ok" -ne 1 ]; then
echo "${ports[@]}"
echo "YAML 语法错误。请检查您的 containers/*.yml 配置文件。"
exit 1
fi
merge_user_args
}
if [ -z $docker_path ]; then
install_docker
fi
[ "$command" == "cleanup" ] && {
$docker_path container prune --filter until=1h
$docker_path image prune --all --filter until=1h
if [ -d /var/discourse/shared/standalone/postgres_data_old ]; then
echo
echo "检测到旧 PostgreSQL 备份数据集群,占用空间为 $(du -hs /var/discourse/shared/standalone/postgres_data_old | awk '{print $1}')"
read -p "您是否要删除它?(y/N): " -n 1 -r && echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "正在删除 /var/discourse/shared/standalone/postgres_data_old 处的旧 PostgreSQL 数据集群..."
rm -rf /var/discourse/shared/standalone/postgres_data_old*
else
exit 1
fi
fi
exit 0
}
docker_version=($($docker_path --version))
docker_version=${test[2]//,/}
restart_policy=${restart_policy:---restart=always}
set_existing_container(){
existing=`$docker_path ps -a | awk '{ print $1, $(NF) }' | grep " $config$" | awk '{ print $1 }'`
}
run_stop() {
set_existing_container
if [ ! -z $existing ]
then
(
set -x
$docker_path stop -t 30 $config
)
else
echo "$config 未启动!"
echo "./discourse-doctor 可能有助于诊断问题。"
exit 1
fi
}
set_run_image() {
run_image=`cat $config_file | $docker_path run $user_args --rm -i -a stdin -a stdout $image ruby -e \
"require 'yaml'; puts YAML.load(STDIN.readlines.join)['run_image']"`
if [ -n "$user_run_image" ]; then
run_image=$user_run_image
elif [ -z "$run_image" ]; then
run_image="$local_discourse/$config"
fi
}
set_boot_command() {
boot_command=`cat $config_file | $docker_path run $user_args --rm -i -a stdin -a stdout $image ruby -e \
"require 'yaml'; puts YAML.load(STDIN.readlines.join)['boot_command']"`
if [ -z "$boot_command" ]; then
no_boot_command=`cat $config_file | $docker_path run $user_args --rm -i -a stdin -a stdout $image ruby -e \
"require 'yaml'; puts YAML.load(STDIN.readlines.join)['no_boot_command']"`
if [ -z "$no_boot_command" ]; then
boot_command="/sbin/boot"
fi
fi
}
merge_user_args() {
local docker_args
docker_args=`cat $config_file | $docker_path run $user_args --rm -i -a stdout -a stdin $image ruby -e \
"require 'yaml'; puts YAML.load(STDIN.readlines.join)['docker_args']"`
if [[ -n "$docker_args" ]]; then
user_args="$user_args_argv $docker_args"
fi
}
run_start() {
if [ -z "$START_CMD_ONLY" ]
then
existing=`$docker_path ps | awk '{ print $1, $(NF) }' | grep " $config$" | awk '{ print $1 }'`
echo $existing
if [ ! -z $existing ]
then
echo "无需操作,您的容器已经启动!"
exit 0
fi
existing=`$docker_path ps -a | awk '{ print $1, $(NF) }' | grep " $config$" | awk '{ print $1 }'`
if [ ! -z $existing ]
then
echo "正在启动现有容器"
(
set -x
$docker_path start $config
)
exit 0
fi
fi
set_template_info
set_volumes
set_links
set_run_image
set_boot_command
# 从容器配置中获取主机名和设置
for envar in "${env[@]}"
do
if [[ $envar == DOCKER_USE_HOSTNAME* ]] || [[ $envar == DISCOURSE_HOSTNAME* ]]
then
# 用作环境变量
eval $envar
fi
done
(
hostname=`hostname -s`
# 覆盖主机名
if [ "$DOCKER_USE_HOSTNAME" = "true" ]
then
hostname=$DISCOURSE_HOSTNAME
else
hostname=$hostname-$config
fi
# 我们必须规范化,只保留允许的字符串,这更全面,但让我们先看看 bash 的表现
# hostname=`$docker_path run $user_args --rm $image ruby -e 'print ARGV[0].gsub(/[^a-zA-Z-]/, "-")' $hostname`
# Docker 增加了更多主机名规则
hostname=${hostname//_/-}
if [ -z "$SKIP_MAC_ADDRESS" ] ; then
mac_address="--mac-address $($docker_path run $user_args -i --rm -a stdout -a stderr $image /bin/sh -c "echo $hostname | md5sum | sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:\1:\2:\3:\4:\5/'")"
fi
if [ ! -z "$START_CMD_ONLY" ] ; then
docker_path="true"
fi
set -x
$docker_path run --shm-size=512m $links $attach_on_run $restart_policy "${env[@]}" "${labels[@]}" -h "$hostname" \
-e DOCKER_HOST_IP="$docker_ip" --name $config -t "${ports[@]}" $volumes $mac_address $user_args \
$run_image $boot_command
)
exit 0
}
run_run() {
set_template_info
set_volumes
set_links
set_run_image
unset ERR
(exec $docker_path run --rm --shm-size=512m $user_args $links "${env[@]}" -e DOCKER_HOST_IP="$docker_ip" -i -a stdin -a stdout -a stderr $volumes $run_image \
/bin/bash -c "$run_command") || ERR=$?
if [[ $ERR > 0 ]]; then
exit 1
fi
}
run_bootstrap() {
set_template_info
base_image=`cat $config_file | $docker_path run $user_args --rm -i -a stdin -a stdout $image ruby -e \
"require 'yaml'; puts YAML.load(STDIN.readlines.join)['base_image']"`
update_pups=`cat $config_file | $docker_path run $user_args --rm -i -a stdin -a stdout $image ruby -e \
"require 'yaml'; puts YAML.load(STDIN.readlines.join)['update_pups']"`
if [[ ! X"" = X"$base_image" ]]; then
image=$base_image
fi
# base_image 可能不总是 discourse/base,
# 让我们确保始终从最新版本构建
pull_image
set_volumes
set_links
if $docker_path run $user_args --rm -i $image gem which pups; then
pups_command="/usr/local/bin/pups --stdin"
else
# 如果 `pups` 未通过 gem 安装在基础镜像中,则回退到 git pull 方法
pups_command="cd /pups &&"
if [[ ! "false" = $update_pups ]]; then
pups_command="$pups_command git pull && git checkout $pups_version &&"
fi
pups_command="$pups_command /pups/bin/pups --stdin"
fi
echo $pups_command
declare -i BOOTSTRAP_EXITCODE
rm -f $cidbootstrap
echo "$input" | $docker_path run --shm-size=512m $user_args $links "${env[@]}" -e DOCKER_HOST_IP="$docker_ip" --cidfile "$cidbootstrap" -i -a stdin -a stdout -a stderr $volumes $image \
/bin/bash -c "$pups_command"
BOOTSTRAP_EXITCODE=$?
CONTAINER_ID=$(cat "$cidbootstrap")
rm -f "$cidbootstrap"
# 表示重试的特殊退出码
if [[ $BOOTSTRAP_EXITCODE -eq 77 ]]; then
$docker_path rm "$CONTAINER_ID"
exit 77
elif [[ $BOOTSTRAP_EXITCODE -gt 0 ]]; then
echo "引导失败,退出码为 $BOOTSTRAP_EXITCODE"
echo "** 引导失败 ** 请向上滚动并查找之前的错误消息,可能不止一条。"
echo "./discourse-doctor 可能有助于诊断问题。"
if [[ -n "$DEBUG" ]]; then
if $docker_path commit "$CONTAINER_ID" $local_discourse/$config-debug; then
echo "** 调试 ** 保留镜像用于诊断 $local_discourse/$config-debug"
else
echo "** 调试 ** 提交容器 $CONTAINER_ID 用于诊断失败"
fi
fi
$docker_path rm "$CONTAINER_ID"
exit 1
fi
sleep 5
$docker_path commit \
-c "LABEL org.opencontainers.image.created=\"$(TZ=UTC date -Iseconds)\"" \
"$CONTAINER_ID" \
$local_discourse/$config || fatal "提交 $CONTAINER_ID 失败"
$docker_path rm "$CONTAINER_ID"
}
case "$command" in
bootstrap)
run_bootstrap
echo "引导成功,要启动请使用 ./launcher start $config"
exit 0
;;
run)
run_run
exit 0
;;
enter)
exec $docker_path exec -it $config /bin/bash --login
;;
stop)
run_stop
exit 0
;;
logs)
$docker_path logs $config
exit 0
;;
restart)
run_stop
run_start
exit 0
;;
start-cmd)
START_CMD_ONLY="1"
run_start
exit 0;
;;
start)
run_start
exit 0
;;
rebuild)
if [ "$(git symbolic-ref --short HEAD)" == "master" ]; then
git branch -m master main
git fetch origin
git branch -u origin/main main
git remote set-head origin -a
fi
if [ "$(git symbolic-ref --short HEAD)" == "main" ]; then
echo "确保启动器是最新的"
git remote update
LOCAL=$(git rev-parse HEAD)
REMOTE=$(git rev-parse @{u})
BASE=$(git merge-base HEAD @{u})
if [ $LOCAL = $REMOTE ]; then
echo "启动器已是最新"
elif [ $LOCAL = $BASE ]; then
echo "正在更新启动器..."
git pull || (echo '更新失败' && exit 1)
echo "启动器已更新,正在重启..."
exec "$0" "${SAVED_ARGV[@]}"
elif [ $REMOTE = $BASE ]; then
echo "您的启动器版本领先于 origin"
else
echo "启动器源已分歧,这仅在开发模式下预期发生"
fi
fi
set_existing_container
if [ ! -z $existing ]
then
echo "正在停止旧容器"
(
set -x
$docker_path stop -t 60 $config
)
fi
run_bootstrap
if [ ! -z $existing ]
then
echo "正在删除旧容器"
(
set -x
$docker_path rm $config
)
fi
run_start
exit 0
;;
destroy)
(set -x; $docker_path stop -t 10 $config && $docker_path rm $config) || (echo "未找到 $config" && exit 0)
exit 0
;;
esac
usage
为了结束此事,在 PM 的一点帮助下,发现是 maxmind 的问题,注释掉它后,bootstrap 成功完成。 ![]()