@@ -109,15 +109,13 @@ git clone https://github.com/TIOJ-INFOR-Online-Judge/tioj-judge.git
109109
110110# Install gems
111111cd " $WORKDIR /tioj"
112+ gem install passenger:' ~> 6' -N
113+ PASSENGER_LOG=$( sudo mktemp -d)
114+ sudo chmod 755 $PASSENGER_LOG
115+ export rvmsudo_secure_path=1
116+ rvmsudo -b bash -c " passenger-install-nginx-module --force-colors --auto --auto-download --languages ruby > $PASSENGER_LOG /log 2>&1; touch $PASSENGER_LOG /finished"
112117MAKEFLAGS=' -j4' bundle install
113118
114- # Setup nginx
115- rvmsudo_secure_path=1 rvmsudo passenger-install-nginx-module --auto --auto-download --languages ruby
116- sudo sed -i " s/^.*nobody.*$/user $USER ;/" /opt/nginx/conf/nginx.conf
117- sudo sed -i ' s/http {/\0\n passenger_app_env production;/' /opt/nginx/conf/nginx.conf
118- sudo sed -i " s|^[^#]*server_name.*localhost.*$|\0\n passenger_enabled on;\n root $( pwd) /public;|" /opt/nginx/conf/nginx.conf
119- sudo sed -Ei " /^ *location \//, /\}/ s|^ {8}|\0# |" /opt/nginx/conf/nginx.conf
120-
121119# Setup database
122120cat << EOF > config/database.yml
123121default: &default
@@ -166,7 +164,7 @@ cd "$WORKDIR/tioj-judge"
166164mkdir -p build
167165cd build
168166cmake -G Ninja ..
169- ninja
167+ ninja -j $(( $(nproc) - 2 ))
170168sudo ninja install
171169
172170sudo tee /etc/tioj-judge.conf << EOF > /dev/null
@@ -176,6 +174,20 @@ parallel = 2
176174max_submission_queue_size = 20
177175EOF
178176
177+ # Setup nginx
178+ cd " $WORKDIR /tioj"
179+ tail -f -n +1 $PASSENGER_LOG /log &
180+ TAIL_PID=$!
181+ until stat $PASSENGER_LOG /finished > /dev/null 2>&1 ; do
182+ sleep 1
183+ done
184+ kill $TAIL_PID
185+ sudo rm -rf $PASSENGER_LOG
186+ sudo sed -i " s/^.*nobody.*$/user $USER ;/" /opt/nginx/conf/nginx.conf
187+ sudo sed -i ' s/http {/\0\n passenger_app_env production;/' /opt/nginx/conf/nginx.conf
188+ sudo sed -i " s|^[^#]*server_name.*localhost.*$|\0\n passenger_enabled on;\n root $( pwd) /public;|" /opt/nginx/conf/nginx.conf
189+ sudo sed -Ei " /^ *location \//, /\}/ s|^ {8}|\0# |" /opt/nginx/conf/nginx.conf
190+
179191# Setup systemctl
180192cat << EOF | sudo tee /etc/systemd/system/nginx.service > /dev/null
181193[Unit]
0 commit comments