Bug Fix: force the network to attacht to trex to start the traffic
[yardstick.git] / api / api-prepare.sh
index c05dbb5..5cc65c9 100755 (executable)
@@ -20,18 +20,36 @@ server {
     index  index.htm index.html;
     location / {
         include uwsgi_params;
-        uwsgi_pass unix:///home/opnfv/repos/yardstick/api/yardstick.sock;
+        uwsgi_pass unix:///var/run/yardstick.sock;
     }
 }
 EOF
+echo "daemon off;" >> /etc/nginx/nginx.conf
 fi
 
 # nginx service start when boot
-cat << EOF >> /root/.bashrc
+supervisor_config='/etc/supervisor/conf.d/yardstick.conf'
 
-nginx_status=\$(service nginx status | grep not)
-if [ -n "\${nginx_status}" ];then
-    service nginx restart
-    uwsgi -i /home/opnfv/repos/yardstick/api/yardstick.ini
-fi
+if [[ ! -e "${supervisor_config}" ]];then
+    cat << EOF > "${supervisor_config}"
+[supervisord]
+nodaemon = true
+
+[program:yardstick_nginx]
+user = root
+command = service nginx restart
+autorestart = true
+
+[program:yardstick_uwsgi]
+user = root
+directory = /home/opnfv/repos/yardstick/api
+command = uwsgi -i yardstick.ini
+autorestart = true
 EOF
+fi
+
+# create api log directory
+mkdir -p /var/log/yardstick
+
+# create yardstick.sock for communicating
+touch /var/run/yardstick.sock