#!/bin/bash set -e set -u # supervisord 配置文件 SUPERVISOR_PARAMS='-c /etc/supervisord.conf' # 创建一些需要的目录 mkdir -p /data/conf /data/run /data/logs/ chmod 711 /data/conf /data/run /data/logs #export WORKER_REDIS_PORT=${REDIS_PORT:6} #export WORKER_REDIS_DB=${REDIS_DB:-0} # 遍历 `/opt/init/*.sh`,然后执行它 if [ "$(ls /opt/init/)" ]; then for cmd in /opt/init/*.sh; do . $cmd done fi # 可能会使用一个交互式的容器. if test -t 0; then # 运行 supervisord 到后台 supervisord $SUPERVISOR_PARAMS # 运行一些命令并退出 # 没有命令时,运行bash if [[ $@ ]]; then eval $@ else export PS1='[\u@\h : \w]\$ ' /bin/bash fi # 运行 supervisord 在前台, 保持直到停止容器. else # 有额外的参数,先执行它. # 可能会有些问题 if [[ $@ ]]; then eval $@ fi supervisord -n $SUPERVISOR_PARAMS fi