run.wsgi.docker.sh
1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#! /bin/sh
#停止容器
echo "正在关闭容器..."
docker stop apache
docker rm apache
curPath=$(readlink -f $(dirname $0))
#寻找模块
echo "在modules下寻找模块..."
map=""
for mod in $(ls $curPath/modules)
do
map="$map -v $curPath/modules/$mod:/usr/src/$mod"
done
#设置日志权限
for mod in $(ls $curPath/modules)
do
chmod -R 777 $curPath/modules/$mod/logs/*
done
#设置端口
port=""
if [ ! -n "$1" ] ;then
port="8888"
echo "未设置端口,使用默认8888端口..."
else
port=$1
echo "端口设置为$1 ..."
fi
#修改httpd.conf
echo "正在修改httpd.conf..."
rm $curPath/httpd.conf
cp $curPath/httpd.conf.sample $curPath/httpd.conf
echo "<VirtualHost *>" >> $curPath/httpd.conf
echo " ServerName apacheflask">>$curPath/httpd.conf
echo " WSGIDaemonProcess yourapplication user=chinadci group=chinadci threads=5">>$curPath/httpd.conf
for mod in $(ls $curPath/modules)
do
echo " WSGIScriptAlias /$mod /usr/src/$mod/run.wsgi">>$curPath/httpd.conf
done
echo " <Directory /usr/src/app>">>$curPath/httpd.conf
echo " WSGIProcessGroup yourapplication">>$curPath/httpd.conf
echo " WSGIApplicationGroup %{GLOBAL}">>$curPath/httpd.conf
echo " Require all granted">>$curPath/httpd.conf
echo " </Directory>">>$curPath/httpd.conf
echo "</VirtualHost>">>$curPath/httpd.conf
#启动容器和apache
echo "正在启动容器..."
set="--privileged=true -e TZ="Asia/Shanghai" --restart=always -e ALLOW_IP_RANGE=0.0.0.0/0"
docker run -d --name apache $set -p $port:80 $map -v $curPath/httpd.conf:/etc/httpd/conf/httpd.conf dci/apache:1.0 /usr/sbin/init
docker exec -d apache systemctl start httpd