Skip to content

Commit 7b125ca

Browse files
committed
gunicorn/make_run.sh file is updated to set workers number automatically.
1 parent 34c9574 commit 7b125ca

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

docker/gunicorn/make_run.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ do
3535
fi
3636
done
3737

38+
let p_num=$(grep -c processor /proc/cpuinfo)*2+1
39+
40+
if [[ "$p_num" == "" ]]; then
41+
echo "this job can't access /proc/cpuinfo. so workers number be setting as 4."
42+
p_num=4
43+
else
44+
echo "p_num is $p_num, workers parameter is $p_num"
45+
fi
46+
3847
if [[ "$fwtype" -eq $django ]]; then
3948
wsgi=${project_name}".wsgi:application"
4049
echo "django wsgi: $wsgi"
@@ -47,6 +56,7 @@ fi
4756

4857
sed 's/project_path/'$project_path'/g' sample_run > $project_name'1'.temp
4958
sed 's/wsgi/'$wsgi'/g' $project_name'1'.temp > $project_name'2'.temp
50-
sed 's/project_name/'$project_name'/g' $project_name'2'.temp > run.sh
59+
sed 's/project_name/'$project_name'/g' $project_name'2'.temp > $project_name'3'.temp
60+
sed 's/worker_number/'$p_num'/g' $project_name'3'.temp > run.sh
5161

5262
rm *.temp

0 commit comments

Comments
 (0)