Deployment for API 83/24683/2
authorchenjiankun <chenjiankun1@huawei.com>
Tue, 22 Nov 2016 16:06:04 +0000 (16:06 +0000)
committerchenjiankun <chenjiankun1@huawei.com>
Wed, 23 Nov 2016 09:51:05 +0000 (09:51 +0000)
JIRA: YARDSTICK-418

Set yardstick.conf in /etc/yardstick/ to config yardstick output way
Set nginx config file
Set nginx service and uwsgi service start when boot

Change-Id: I5749042ae1b05feaf895cb0abffed7f9194b9cee
Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
api/api-prepare.sh [new file with mode: 0755]
api/yardstick.ini [new file with mode: 0644]
api/yardstick.sock [new file with mode: 0644]
docker/Dockerfile
install.sh

diff --git a/api/api-prepare.sh b/api/api-prepare.sh
new file mode 100755 (executable)
index 0000000..712ad83
--- /dev/null
@@ -0,0 +1,59 @@
+#!/bin/bash
+
+# yardstick output config
+output_config='/etc/yardstick/yardstick.conf'
+
+if [[ ! -e "${output_config}" ]];then
+    gateway_ip=$(ip route | grep default | awk '{print $3}')
+    echo "${gateway_ip}"
+
+    install -d /etc/yardstick -m 0755 -o root
+
+    cat << EOF >> "${output_config}"
+[DEFAULT]
+debug = True
+dispatcher = influxdb
+
+[dispatcher_file]
+file_path = /tmp/yardstick.out
+
+[dispatcher_http]
+timeout = 5
+# target = http://127.0.0.1:8000/results
+
+[dispatcher_influxdb]
+timeout = 5
+target = http://${gateway_ip}:8086
+db_name = yardstick
+username = root
+password = root
+EOF
+fi
+
+# nginx config
+nginx_config='/etc/nginx/conf.d/yardstick.conf'
+
+if [[ ! -e "${nginx_config}" ]];then
+
+    cat << EOF >> "${nginx_config}"
+server {
+    listen 5000;
+    server_name localhost;
+    index  index.htm index.html;
+    location / {
+        include uwsgi_params;
+        uwsgi_pass unix:///home/opnfv/repos/yardstick/api/yardstick.sock;
+    }
+}
+EOF
+fi
+
+# nginx service start when boot
+cat << EOF >> /root/.bashrc
+
+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
+EOF
diff --git a/api/yardstick.ini b/api/yardstick.ini
new file mode 100644 (file)
index 0000000..5350229
--- /dev/null
@@ -0,0 +1,16 @@
+[uwsgi]
+master = true
+debug = true
+chdir = /home/opnfv/repos/yardstick/api
+module = server
+plugins = python
+processes = 10
+threads = 5
+async = true
+max-requests = 5000
+chmod-socket = 666
+callable = app
+enable-threads = true
+close-on-exec = 1
+daemonize=/home/kklt/kklt/api/uwsgi.log
+socket = /home/opnfv/repos/yardstick/api/yardstick.sock
diff --git a/api/yardstick.sock b/api/yardstick.sock
new file mode 100644 (file)
index 0000000..e69de29
index fba6e20..36db2bb 100644 (file)
@@ -43,6 +43,9 @@ RUN apt-get update && apt-get install -y \
     python-dev \
     libxml2-dev \
     libxslt1-dev \
+    nginx \
+    uwsgi \
+    uwsgi-plugin-python \
     python-setuptools && \
     easy_install -U setuptools
 
@@ -60,6 +63,10 @@ RUN cd ${YARDSTICK_REPO_DIR} && easy_install -U pip
 RUN cd ${YARDSTICK_REPO_DIR} && pip install -r requirements.txt
 RUN cd ${YARDSTICK_REPO_DIR} && pip install .
 
+RUN ${YARDSTICK_REPO_DIR}/api/api-prepare.sh
+
+EXPOSE 5000
+
 ADD http://download.cirros-cloud.net/0.3.3/cirros-0.3.3-x86_64-disk.img /home/opnfv/images/
 ADD http://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img /home/opnfv/images/
 
index 80fc1e5..8fdd075 100755 (executable)
@@ -13,6 +13,9 @@ apt-get update && apt-get install -y \
     python-dev \
     libxml2-dev \
     libxslt1-dev \
+    nginx \
+    uswgi \
+    uwsgi-plugin-python \
     python-setuptools && \
     easy_install -U setuptools