浏览代码

上传文件至 ''

stone 5 年之前
父节点
当前提交
44dd78143b
共有 18 个文件被更改,包括 1180 次插入1 次删除
  1. 62 0
      .drone.yml
  2. 10 0
      Dockerfile
  3. 22 0
      Dockerfile-basenew
  4. 27 0
      Dockerfile-baseold
  5. 88 0
      Jenkinsfile
  6. 1 1
      README.md
  7. 167 0
      deploy-tmp.yaml
  8. 80 0
      deployment.yaml
  9. 14 0
      entrypoint.sh
  10. 10 0
      hostlist.conf
  11. 9 0
      nginxlog_cut.sh
  12. 233 0
      ppctl.py
  13. 1 0
      release
  14. 347 0
      resin.conf
  15. 2 0
      root
  16. 1 0
      rsyncd.wapage
  17. 31 0
      supervisord.conf
  18. 75 0
      www.conf

+ 62 - 0
.drone.yml

@@ -0,0 +1,62 @@
+---
+kind: pipeline
+name: wapage2web
+
+steps:
+ - name: build
+   image: hub.evbj.easou.com/dev/drone-agent-custom:v5.0.0
+  # pull: always
+   privileged: true
+   environment:
+     JNLP_ENV: qa
+     JNLP_REPO: hub.evbj.easou.com
+     JNLP_TAG: v1base.0.1
+     JNLP_CONTAINER_PORT: 8080
+     JNLP_INGRESS: nginx
+     JNLP_SVC_MODE: http
+     JNLP_STORAGE_CLASS: rbd
+     JNLP_DOMAIN: .ieasou.cn
+     JNLP_CONTROL: StatefulSet
+     JNLP_REPLICAS: 2
+     JNLP_STORAGE_CAPACITY: 100Gi
+     JNLP_MOUNT_PATH: /data
+     JNLP_LIVENESS_INIT: 60
+     JNLP_LIVENESS_PER: 10
+     JNLP_READINESS_INIT: 60
+     JNLP_READINESS_PER: 10
+   commands:
+     - wrapper.sh  /bin/sh
+     - docker --config /etc/docker build -t "$JNLP_REPO/$JNLP_ENV/$DRONE_REPO_NAME:$JNLP_TAG" . -f Dockerfile
+     - docker --config /etc/docker push "$JNLP_REPO/$JNLP_ENV/$DRONE_REPO_NAME:$JNLP_TAG"
+     - python ppctl.py -b
+     - python ppctl.py -a
+     - python ppctl.py -d
+    # - python ppctl.py -c
+
+ - name: success
+   image: clem109/drone-wechat
+   settings:
+     corpid: ww419ee4063735e1c0
+     corp_secret: zpiRBLETH9eLwIMQ4eJ_r_dcm3BPSGeLHvTcft8Ot-M
+     agent_id: 1000004
+     title: "Pipeline ${DRONE_REPO_NAME} Success"
+     description: "${DRONE_BUILD_LINK} 部署完成"
+     msg_url: ${DRONE_BUILD_LINK}
+     btn_txt: "否"
+   when:
+     status:
+     - success
+
+ - name: failure
+   image: clem109/drone-wechat
+   settings:
+     corpid: ww419ee4063735e1c0
+     corp_secret: zpiRBLETH9eLwIMQ4eJ_r_dcm3BPSGeLHvTcft8Ot-M
+     agent_id: 1000004
+     title: "Pipeline ${DRONE_REPO_NAME} Failure"
+     description: "${DRONE_BUILD_LINK} 部署失败,请检查配置!"
+     msg_url: ${DRONE_BUILD_LINK}
+     btn_txt: "否"
+   when:
+     status:
+     - failure

+ 10 - 0
Dockerfile

@@ -0,0 +1,10 @@
+FROM hub.evbj.easou.com/qa/wapage2web:v1base.0.1
+MAINTAINER scofield[scofield_shi@easou.cn]
+
+COPY release /etc/release
+RUN export RELEASE=`head -n 1 /etc/release` \
+	&& rsync -vzrtopg --progress $RELEASE/wapage2web_baidu.war /app/soft/resin-pro-3.1.16/webapps/ROOT.war --password-file=/etc/rsyncd.wapage
+
+#start resin
+ENTRYPOINT ["entrypoint.sh"]
+CMD ["/usr/bin/supervisord"]

+ 22 - 0
Dockerfile-basenew

@@ -0,0 +1,22 @@
+FROM hub.evbj.easou.com/dev/centos68-resin:3.1.16-jdk7
+MAINTAINER scofield[scofield_shi@easou.cn]
+
+COPY release /etc/release
+COPY resin.conf /app/soft/resin-pro-3.1.16/conf/resin.conf
+COPY entrypoint.sh /usr/bin/entrypoint.sh
+COPY rsyncd.wapage /etc/rsyncd.wapage
+COPY release /etc/release
+
+RUN yum install -y rsync \
+	&& yum install -y wget rsync epel-release \
+	&& yum install -y vixie-cron \
+	&& yum install -y supervisor \
+	&& chmod +x /usr/bin/entrypoint.sh \
+	&& export RELEASE=`head -n 1 /etc/release` \
+	&& rsync -vzrtopg --progress $RELEASE/wapage2web_baidu.war /app/soft/resin-pro-3.1.16/webapps/ROOT.war --password-file=/etc/rsyncd.wapage
+
+COPY supervisord.conf /etc/supervisord.conf
+
+#start resin
+ENTRYPOINT ["entrypoint.sh"]
+CMD ["/usr/bin/supervisord"]

+ 27 - 0
Dockerfile-baseold

@@ -0,0 +1,27 @@
+FROM hub.evbj.easou.com/pro/dashouye:1.0.1
+MAINTAINER guizhong[guizhong_liu@staff.easou.com]
+
+
+ADD resin.conf /app/soft/resin-pro-3.1.6/conf/resin.conf
+ADD nginxlog_cut.sh /cron/root/nginxlog_cut.sh
+ADD hostlist.conf /app/soft/tengine/conf/vhosts/www/hostlist.conf
+ADD www.conf /app/soft/tengine/conf/vhosts/www/www.conf
+ADD root /var/spool/cron/root
+ADD entrypoint.sh /usr/bin/entrypoint.sh
+ADD resin.ini /etc/supervisor/conf.d/resin.ini
+ADD rsyncd.wapage /etc/rsyncd.wapage
+ADD release /etc/release
+
+
+RUN yum install -y rsync \
+	&& rm -rf /data/project/* \
+	&& rm -rf /app/soft/flume \
+	&& chmod 600 /etc/rsyncd.wapage \
+	&& chmod +x /usr/bin/entrypoint.sh \
+	&& chmod +x /cron/root/nginxlog_cut.sh \
+	&& export RELEASE=`head -n 1 /etc/release` \
+	&& rsync -vzrtopg --progress $RELEASE/wapage2web_baidu.war /app/soft/resin-pro-3.1.6/webapps/ROOT.war --password-file=/etc/rsyncd.wapage
+ 
+#start resin
+ENTRYPOINT ["entrypoint.sh"]
+CMD ["/usr/bin/supervisord","-c", "/etc/supervisor/supervisord.conf"]

+ 88 - 0
Jenkinsfile

@@ -0,0 +1,88 @@
+def label = "jenkins-agent"
+podTemplate(name: label , cloud: 'kubernetes',
+  namespace: 'cicd', 
+  label: label,
+  serviceAccount: 'default', 
+  envVars: [
+      // JNLP_ENV环境变量需要根据实际情况修改,例如:qa pro op 
+      // 此处op表示,你需要将应用部署到k8s的op命名空间下
+      envVar(key: "JNLP_ENV", value: "pro"),    
+      // 镜像版本号,如果是开发自己测试,可以默认;如果默认,每次更新镜像都会覆盖     
+      // 实际服务端口,例如resin,端口就是8080
+      envVar(key: "JNLP_TAG", value: "v1.0.36"),
+      envVar(key: "JNLP_CONTAINER_PORT", value: "80"),
+      // 项目编译后生成的包名  
+      envVar(key: "JNLP_WAR", value: "ROOT.war"),
+      envVar(key: "JNLP_INGRESS", value: "nginx"),
+      // tcp服务填写: tcp; http服务填写: http(默认)
+      envVar(key: "JNLP_SVC_MODE", value: "http"),
+      // 以下是Kubernetes deploy.yaml部署文件,默认情况下不作修改,保持默认值即可 !!!
+      envVar(key: "JNLP_IMAGE", value: "${JOB_BASE_NAME}"),
+      envVar(key: "JNLP_CONTROL_NAME", value: "${JOB_BASE_NAME}"),
+      envVar(key: "JNLP_STORAGE_CLASS", value: "ceph"),
+      envVar(key: "JNLP_HUB", value: "hub.evbj.easou.com"),
+      envVar(key: "JNLP_DOMAIN", value: ".evbj.easou.com"),
+      envVar(key: "JNLP_CONTROL", value: "StatefulSet"),
+      envVar(key: "JNLP_REPLICAS", value: "3"),
+      envVar(key: "JNLP_STORAGE_CAPACITY", value: "100Gi"),
+      envVar(key: "JNLP_MOUNT_PATH", value: "/data/logs"),
+      // 容器状态健康检查,默认容器启动60秒开始检查,如果检查失败会重启容器
+      // 请根据服务启动时间修改检查时间
+      // 后liveness每隔10秒检查服务是否可用,连续3次不可用,立即重启容器
+      envVar(key: "JNLP_LIVENESS_INIT", value: "60"),
+      envVar(key: "JNLP_LIVENESS_PER", value: "10"),
+      // 容器服务状态健康检查,默认容器启动60秒开始检查,如果检查失败,则该pod不会被加入负载均衡器参与流量调度
+      // 请根据服务初始化时间修改检查时间
+      // 后续readiness每隔10秒检查服务是否可用,连续3次不可用,立即从负载均衡去移除
+      envVar(key: "JNLP_READINESS_INIT", value: "60"),
+      envVar(key: "JNLP_READINESS_PER", value: "10")
+  ],
+  containers: [
+    containerTemplate(
+        name: 'jnlp',
+        image: 'hub.evbj.easou.com/dev/jnlp-slave:v2.0.0',
+        ttyEnabled: true,
+        privileged: true,
+        alwaysPullImage: true), 
+    containerTemplate(
+        name: 'jnlp-slave',
+        image: 'hub.evbj.easou.com/dev/jenkins-slave:v3.0.0',
+        command: 'wrapper.sh /bin/sh',
+        ttyEnabled: true,
+        privileged: true,
+        alwaysPullImage: true),
+    containerTemplate(
+        name: 'kubectl',
+        image: 'hub.evbj.easou.com/dev/kubectl:v3.0.0',
+        command: '/bin/sh',
+        ttyEnabled: true,
+        privileged: true,
+        alwaysPullImage: true)
+    ],
+) {
+  node(label) {
+        stage('Build') {
+          container('jnlp-slave') {
+                deleteDir()
+                checkout scm
+                sh 'printenv|grep JNLP'
+                sh 'docker --config /etc/docker build -t ${JNLP_HUB}/${JNLP_ENV}/${JNLP_IMAGE}:${JNLP_TAG} . -f Dockerfile'
+                sh 'docker --config /etc/docker push ${JNLP_HUB}/${JNLP_ENV}/${JNLP_IMAGE}:${JNLP_TAG}'
+                sh 'docker --config /etc/docker rmi ${JNLP_HUB}/${JNLP_ENV}/${JNLP_IMAGE}:${JNLP_TAG} --force'
+          }
+        }
+        stage('Deploy') {
+          container('kubectl') {
+              // -b 生成部署时的配置文件
+              sh 'python ppctl.py -b'
+              // -a 部署服务到kubernetes平台
+              sh 'python ppctl.py -a'
+              // -c 检查服务部署状态
+              sh 'python ppctl.py -c'
+              // -d 执行域名解析
+              //sh 'python ppctl.py -d'
+          }
+        }
+    }
+}
+

+ 1 - 1
README.md

@@ -1,2 +1,2 @@
-# wapage2misc
+# wapage2web
 

+ 167 - 0
deploy-tmp.yaml

@@ -0,0 +1,167 @@
+---
+apiVersion: apps/v1
+kind: $JNLP_CONTROL
+metadata:
+  name: $DRONE_REPO_NAME
+  namespace: $JNLP_ENV
+  labels:
+    app: $DRONE_REPO_NAME
+spec:
+  serviceName: $DRONE_REPO_NAME
+  replicas: $JNLP_REPLICAS
+  selector:
+    matchLabels:
+      app: $DRONE_REPO_NAME
+  template:
+    metadata:
+      labels:
+        app: $DRONE_REPO_NAME
+    spec:
+      terminationGracePeriodSeconds: 180
+      initContainers:
+        - name: init
+          image: $JNLP_REPO/dev/busybox
+          command: ["chmod","777","-R","$JNLP_MOUNT_PATH"]
+          imagePullPolicy: Always
+          volumeMounts:
+          - name: volume
+            mountPath: $JNLP_MOUNT_PATH
+      containers:
+      - name: $DRONE_REPO_NAME
+        image: $JNLP_REPO/$JNLP_ENV/$DRONE_REPO_NAME:$JNLP_TAG
+        imagePullPolicy: Always
+        ports:
+        - containerPort: $JNLP_CONTAINER_PORT
+          name: port
+        volumeMounts:
+        - name: volume
+          mountPath: $JNLP_MOUNT_PATH
+        livenessProbe:
+          tcpSocket:
+            port: $JNLP_CONTAINER_PORT
+          initialDelaySeconds: $JNLP_LIVENESS_INIT
+          periodSeconds: $JNLP_LIVENESS_PER
+        readinessProbe:
+          tcpSocket:
+            port: $JNLP_CONTAINER_PORT
+          initialDelaySeconds: $JNLP_READINESS_INIT
+          periodSeconds: $JNLP_READINESS_PER
+  volumeClaimTemplates:
+  - metadata:
+      name: volume
+    spec:
+      accessModes: ["ReadWriteOnce"]
+      storageClassName: rbd
+      resources:
+        requests:
+          storage: $JNLP_STORAGE_CAPACITY
+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: $DRONE_REPO_NAME-svc
+  namespace: $JNLP_ENV
+  labels:
+    app: $DRONE_REPO_NAME-svc
+spec:
+  type: NodePort
+  ports:
+  - port: $JNLP_CONTAINER_PORT
+    targetPort: $JNLP_CONTAINER_PORT
+  selector:
+    app: $DRONE_REPO_NAME
+---
+apiVersion: extensions/v1beta1
+kind: Ingress
+metadata:
+  name: $DRONE_REPO_NAME-ingress
+  namespace: $JNLP_ENV
+  annotations:
+    kubernetes.io/ingress.class: $JNLP_INGRESS
+spec:
+  rules:
+  - host: www.easou.cn 
+    http:
+      paths:
+      - path: /
+        backend:
+          serviceName: $JNLP_CONTROL_NAME-svc
+          servicePort: $JNLP_CONTAINER_PORT
+  - host: wap.easou.cn
+    http:
+      paths:
+      - path: /
+        backend:
+          serviceName: $JNLP_CONTROL_NAME-svc
+          servicePort: $JNLP_CONTAINER_PORT
+  - host: easou.cn
+    http:
+      paths:
+      - path: /
+        backend:
+          serviceName: $JNLP_CONTROL_NAME-svc
+          servicePort: $JNLP_CONTAINER_PORT
+  - host: a.easou.cn
+    http:
+      paths:
+      - path: /
+        backend:
+          serviceName: $JNLP_CONTROL_NAME-svc
+          servicePort: $JNLP_CONTAINER_PORT
+  - host: www.appeasou.com 
+    http:
+      paths:
+      - path: /
+        backend:
+          serviceName: $JNLP_CONTROL_NAME-svc
+          servicePort: $JNLP_CONTAINER_PORT
+  - host: wap.appeasou.com
+    http:
+      paths:
+      - path: /
+        backend:
+          serviceName: $JNLP_CONTROL_NAME-svc
+          servicePort: $JNLP_CONTAINER_PORT
+  - host: appeasou.com
+    http:
+      paths:
+      - path: /
+        backend:
+          serviceName: $JNLP_CONTROL_NAME-svc
+          servicePort: $JNLP_CONTAINER_PORT
+  - host: a.appeasou.com
+    http:
+      paths:
+      - path: /
+        backend:
+          serviceName: $JNLP_CONTROL_NAME-svc
+          servicePort: $JNLP_CONTAINER_PORT
+
+  - host: www.easou.com 
+    http:
+      paths:
+      - path: /
+        backend:
+          serviceName: $JNLP_CONTROL_NAME-svc
+          servicePort: $JNLP_CONTAINER_PORT
+  - host: wap.easou.com
+    http:
+      paths:
+      - path: /
+        backend:
+          serviceName: $JNLP_CONTROL_NAME-svc
+          servicePort: $JNLP_CONTAINER_PORT
+  - host: easou.com
+    http:
+      paths:
+      - path: /
+        backend:
+          serviceName: $JNLP_CONTROL_NAME-svc
+          servicePort: $JNLP_CONTAINER_PORT
+  - host: a.easou.com
+    http:
+      paths:
+      - path: /
+        backend:
+          serviceName: $JNLP_CONTROL_NAME-svc
+          servicePort: $JNLP_CONTAINER_PORT

+ 80 - 0
deployment.yaml

@@ -0,0 +1,80 @@
+---
+apiVersion: apps/v1
+kind: $JNLP_CONTROL
+metadata:
+  name: $JNLP_CONTROL_NAME
+  namespace: $JNLP_ENV
+  labels:
+    app: $JNLP_CONTROL_NAME
+spec:
+  serviceName: $JNLP_CONTROL_NAME
+  replicas: $JNLP_REPLICAS
+  selector:
+    matchLabels:
+      app: $JNLP_CONTROL_NAME
+  template:
+    metadata:
+      labels:
+        app: $JNLP_CONTROL_NAME
+    spec:
+      terminationGracePeriodSeconds: 180
+      initContainers:
+        - name: init
+          image: hub.evbj.easou.com/dev/busybox
+          command: ["chmod","777","-R","$JNLP_MOUNT_PATH"]
+          imagePullPolicy: Always
+          volumeMounts:
+          - name: volume
+            mountPath: $JNLP_MOUNT_PATH
+      containers:
+      - name: $JNLP_IMAGE
+        image: $JNLP_HUB/$JNLP_ENV/$JNLP_IMAGE:$JNLP_TAG
+        imagePullPolicy: Always
+        ports:
+        - containerPort: $JNLP_CONTAINER_PORT
+          name: port
+        volumeMounts:
+        - name: volume
+          mountPath: $JNLP_MOUNT_PATH
+        livenessProbe:
+          tcpSocket:
+            port: $JNLP_CONTAINER_PORT
+          initialDelaySeconds: $JNLP_LIVENESS_INIT
+          periodSeconds: $JNLP_LIVENESS_PER
+        readinessProbe:
+          tcpSocket: 
+            port: $JNLP_CONTAINER_PORT
+          initialDelaySeconds: $JNLP_READINESS_INIT
+          periodSeconds: $JNLP_READINESS_PER
+  volumeClaimTemplates:
+  - metadata:
+      name: volume
+    spec:
+      accessModes: ["ReadWriteOnce"]
+      storageClassName: rbd
+      resources:
+        requests:
+          storage: $JNLP_STORAGE_CAPACITY
+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: $JNLP_CONTROL_NAME-svc
+  namespace: $JNLP_ENV
+  labels:
+    app: $JNLP_CONTROL_NAME-svc
+spec:
+  type: NodePort
+  ports:
+  - port: $JNLP_CONTAINER_PORT
+    targetPort: $JNLP_CONTAINER_PORT
+  selector:
+    app: $JNLP_CONTROL_NAME
+---
+apiVersion: extensions/v1beta1
+kind: Ingress
+metadata:
+  name: $JNLP_CONTROL_NAME-ing
+  namespace: $JNLP_ENV
+  annotations:
+    kubernetes.io/ingress.class: $JNLP_INGRESS

+ 14 - 0
entrypoint.sh

@@ -0,0 +1,14 @@
+#!/bin/bash
+
+set -e
+set -o pipefail
+chkconfig  --level 35 crond on
+/sbin/service crond restart
+/sbin/service rsyslog start
+mkdir -p /var/spool/cron/root
+cd /var/spool/cron && chmod -R 600 root
+mkdir -p /data/log/devlog  /data/log/other  /data/log/qd  /data/project
+rm -rf /data/project/*
+mv /app/soft/resin-pro-3.1.16/webapps/ROOT.war /data/project/ROOT.war
+
+exec "$@"

+ 10 - 0
hostlist.conf

@@ -0,0 +1,10 @@
+upstream backend {
+##<hostlist>##
+server 127.0.0.1:8080;
+##</hostlist>##
+#check interval=3000 rise=2 fall=5 timeout=1000 type=http;
+#check_http_send "GET /apache_router.jsp HTTP/1.0\r\n\r\n";
+#check_http_send "GET / HTTP/1.0\r\n\r\n";
+#check_http_expect_alive http_2xx http_3xx;
+#keepalive 32;
+}

+ 9 - 0
nginxlog_cut.sh

@@ -0,0 +1,9 @@
+#!/bin/bash
+log_path=/log/nginx/visit
+DATE=$(date +%Y%m%d%H --date='1 hour ago')
+mv $log_path/access.log $log_path/access.log.$DATE
+mv $qd_log_path/access.log $qd_log_path/access.log.$DATE
+kill -USR1 `cat /app/soft/tengine/nginx.pid`
+
+find /log/ -daystart -type f -mtime +1 -exec rm -f '{}' ';'
+find /data/wapage/log/indexpage/ -daystart -type f -mtime +3 -exec rm -f '{}' ';'

+ 233 - 0
ppctl.py

@@ -0,0 +1,233 @@
+#!/usr/bin/python
+# -*- coding: UTF-8 -*-
+from __future__ import print_function
+import os
+import commands
+import httplib, urllib
+import json
+import time
+from kubernetes.client.rest import ApiException
+from pprint import pprint
+from kubernetes import client, config
+import sys, getopt, random
+from aliyunsdkcore.client import AcsClient
+from aliyunsdkcore.acs_exception.exceptions import ClientException
+from aliyunsdkcore.acs_exception.exceptions import ServerException
+from aliyunsdkalidns.request.v20150109.AddDomainRecordRequest import AddDomainRecordRequest
+from aliyunsdkalidns.request.v20150109.DeleteDomainRecordRequest import DeleteDomainRecordRequest
+from aliyunsdkalidns.request.v20150109.DescribeDomainRecordsRequest import DescribeDomainRecordsRequest
+
+
+
+JNLP_ENV = os.getenv('JNLP_ENV')
+JNLP_TAG = os.getenv('JNLP_TAG')
+JNLP_CONTAINER_PORT = os.getenv('JNLP_CONTAINER_PORT')
+# JNLP_WAR = os.getenv('JNLP_WAR')
+JNLP_INGRESS = os.getenv('JNLP_INGRESS')
+JNLP_IMAGE = os.getenv('JNLP_IMAGE')
+JNLP_CONTROL_NAME = os.getenv('DRONE_REPO_NAME')
+JNLP_STORAGE_CLASS = os.getenv('JNLP_STORAGE_CLASS')
+JNLP_DOMAIN = os.getenv('JNLP_DOMAIN')
+JNLP_CONTROL = os.getenv('JNLP_CONTROL')
+JNLP_REPLICAS = os.getenv('JNLP_REPLICAS')
+JNLP_STORAGE_CAPACITY = os.getenv('JNLP_STORAGE_CAPACITY')
+JNLP_MOUNT_PATH = os.getenv('JNLP_MOUNT_PATH')
+JNLP_SVC_MODE = os.getenv('JNLP_SVC_MODE')
+NGINX_SVC = str(JNLP_ENV) + '/' + str(JNLP_CONTROL_NAME) + '-svc:' + str(JNLP_CONTAINER_PORT)
+NGINX_PORT = os.getenv('JNLP_CONTAINER_PORT')
+RECORD_NAME = os.getenv('JNLP_ENV') + "-" + os.getenv('DRONE_REPO_NAME')
+INGRESS_LIST_IN = ["10.26.32.137"]
+INGRESS_LIST_PUB = ["120.192.70.105"]
+NGINX_RECORD_IP = random.sample(INGRESS_LIST_PUB, 1)[0]
+DOMAINNAME = os.getenv('JNLP_DOMAIN').strip('.')
+
+
+# 生成deploy.yaml文件
+def deployYamlCreate():
+    tmpctl = '''
+    config=`env|grep JNLP`
+    template=`cat ./deploy-tmp.yaml`
+    printf "$config\ncat << EOF\n$template\nEOF" | bash > ./deploy.yaml
+    '''
+    f1 = open("tempshell.sh","w")
+    f1.writelines(tmpctl)
+    f1.close()
+    status,output = commands.getstatusoutput("sh tempshell.sh && rm -f tempshell.sh")
+    print("code:" + str(status) + str(output) + "; create deploy.yaml success !!!")
+    return status,output
+
+
+# 生成Dockerfile文件
+def DockerfileCreate():
+    tmp = '''
+    onfig=`env|grep JNLP`
+    template=`cat ./Dockerfile`
+    printf "$config\ncat << EOF\n$template\nEOF" | bash > ./Dockerfile
+    '''
+    f2 = open("tmp.sh","w")
+    f2.writelines(tmp)
+    f2.close()
+    status,output = commands.getstatusoutput("sh tmp.sh && rm -f tmp.sh")
+    print("code:" + str(status) + str(output) + "; create Dockerfile success !!!")
+    return
+
+
+# 更新haproxy configmap.json配置文件,生成TCP服务转发记录
+def updateConfigMap(file):
+    if JNLP_SVC_MODE == "tcp":
+        data = {}
+        data[NGINX_PORT] = NGINX_SVC
+        status, output = commands.getstatusoutput("kubectl  get cm  tcp-services -n  ingress-nginx -o=json")
+        tempdict = eval(output)
+        tempdict['data'][NGINX_PORT] = NGINX_SVC
+        newdata = tempdict['data']
+        print(newdata,status) 
+        old_str = "CMDATA"
+        new_str = str(newdata).replace("'",'"')
+        with open(file, "r") as f1,open("%s.bak" % file, "w" ) as f2:
+            for line in f1:
+                if old_str in line:
+                    line = line.replace(old_str, new_str)
+                f2.write(line)
+        os.remove(file)
+        os.rename("%s.bak" % file, file)
+        cmStatus = "1"
+    else:
+        print("****** Nginx Tcp Services Configmap.json Do Not Update ******")
+        cmStatus = "0"
+    return cmStatus
+
+# 部署应用到kubernetes平台
+def deployToKube():
+    cmStatus = updateConfigMap("configmap.json")
+    appStatus = commands.getoutput("kubectl  get sts $JNLP_CONTROL_NAME -n $JNLP_NAMESPACE|grep $JNLP_CONTROL_NAME|wc -l")
+    if appStatus == "1" and cmStatus == "1":
+        print("Warning:" + JNLP_CONTROL_NAME + " is already, i will update it and update nginx tcp proxy !!!")
+        apply_out = commands.getoutput("kubectl apply -f ./deploy.yaml && kubectl apply -f ./configmap.json")
+        print("===>>> kubectl apply output <<<===")
+        print(apply_out)
+    elif appStatus == "1" and cmStatus == "0":
+        print("Warning:" + JNLP_CONTROL_NAME + " is already, i will update it !!!")
+        apply_out = commands.getoutput("kubectl apply -f ./deploy.yaml")
+        print("===>>> kubectl apply output <<<===")
+        print(apply_out)
+    elif appStatus != "1" and cmStatus == "1":
+        apply_out = commands.getoutput("kubectl apply -f ./deploy.yaml && kubectl apply -f ./configmap.json")
+        print("===>>> kubectl apply output <<<===")
+        print(apply_out)
+        print("===>>> apply is successfull <<<===")
+    else:
+        apply_out = commands.getoutput("kubectl apply -f ./deploy.yaml")
+        print("===>>> kubectl apply output <<<===")
+        print(apply_out)
+        print("===>>> apply app successfull <<<===")
+    return
+
+
+# 部署应用状态获取
+def deployStatus():
+    kubeconfig = config.kube_config.load_kube_config(config_file="/root/.kube/config")
+    appsv1_api_instance = client.AppsV1Api(kubeconfig)
+    namespace = JNLP_ENV
+    stsname = JNLP_CONTROL_NAME
+    pretty = "true"
+    for x in range(20):
+        try:
+            sts_response = appsv1_api_instance.read_namespaced_stateful_set_status(stsname, namespace, pretty=pretty)
+            if sts_response.status.replicas == sts_response.status.ready_replicas :
+                print("===>>> " +stsname + " is RUNNING <<<===")
+                chk_status = 1
+                break
+            else:
+                if x < 40:
+                    time.sleep(15)
+                else:
+                    chk_status = 0
+                    print(stsname + " status check fail !!! , Please contact kubernetes systen administrator")
+        except ApiException as e:
+            print("Exception when calling CoreV1Api->list_namespaced_pod: %s\n" % e)
+    return chk_status
+
+
+# DNS解析
+# 域名由jenkins项目名+命名空间+dns域组合而成
+# 如果域名已存在,不会再更新
+def dnsAllocation():
+    if JNLP_INGRESS == "nginx":
+        httpClient = httplib.HTTPConnection("opsadmin.evbj.easou.com", 80, timeout=30)
+        headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain"}
+        params = urllib.urlencode({'method': 'add', 'type': 'record', 'domain_id': 24, 'record_type': 'A', 'record_name': RECORD_NAME ,'record_ip': NGINX_RECORD_IP , 'record_ttl': 180})
+        httpClient.request("POST", "/dns/dnsapi/?token=c2d1856be235a3207cd03b6f4d3c4094", params, headers)
+        response = httpClient.getresponse().read()
+        jstr = json.loads(response)
+        nsStatus = jstr['status']
+        print(NGINX_RECORD_IP)
+        if nsStatus == "-501":
+            print(JNLP_ENV + "-" + JNLP_CONTROL_NAME + JNLP_DOMAIN + " is already exist")
+        elif nsStatus == "0":
+            httpClient = httplib.HTTPConnection("opsadmin.evbj.easou.com", 80, timeout=30)
+            httpClient.request("POST", "/dns/mkconfig/?token=c2d1856be235a3207cd03b6f4d3c4094")
+            response = httpClient.getresponse().read()
+            jstr = json.loads(response)
+            upStatus = jstr['status']
+            print(JNLP_ENV + "-" + JNLP_CONTROL_NAME + JNLP_DOMAIN + " " +upStatus + " add successfull !!!")
+        else:
+            print("*****Please contact DNS systen administrator*****")
+    else :
+        print(">>> Ingress error, Only nginx !!! <<<")
+    return
+
+def cloudDns():
+    if JNLP_INGRESS == "nginx":
+        client = AcsClient('LTAI4LibOCW5ilIa', 'NiA9OumXJDHp4TwLwXWcCKGoDgDjms', 'cn-hangzhou')
+
+        # describe record
+        request = DescribeDomainRecordsRequest()
+        request.set_accept_format('json')
+        request.set_DomainName(DOMAINNAME)
+        request.set_RRKeyWord(RECORD_NAME)
+        response = client.do_action_with_exception(request)
+        jsondata = json.loads(response)
+        # print(response)
+        if jsondata['TotalCount'] != 0:
+            print(RECORD_NAME + "." + DOMAINNAME + " is already exists <<<")
+        else :
+        # add record
+            request = AddDomainRecordRequest()
+            request.set_accept_format('json')
+            request.set_Value(NGINX_RECORD_IP)
+            request.set_Type("A")
+            request.set_RR(RECORD_NAME)
+            request.set_DomainName(DOMAINNAME)
+            response = client.do_action_with_exception(request)
+            # print(response)
+            print(RECORD_NAME + "." + DOMAINNAME + " add sucess <<<")
+    else :
+        print(">>> Ingress error, Only nginx !!! <<<")
+    return
+
+def main(argv=None):
+    if argv is None:
+        args = sys.argv[1:]
+        for opt_name in args :
+            if opt_name in ('-a','--apply'):
+                print("===>>> deploy app to kubernetes <<<===")
+                deployToKube()
+                time.sleep(10)
+                sys.exit()
+            if opt_name in ('-b','--build'):
+                print("===>>> create deploy.yaml <<<===")
+                deployYamlCreate()
+                sys.exit()
+            if opt_name in ('-c','--check'):
+                print("===>>> app status check <<<===")
+                deployStatus()
+                sys.exit()
+            if opt_name in ('-d','--dns'):
+                print("===>>> add/update dns resolve <<<===")
+                cloudDns()
+                sys.exit()
+    return
+
+if __name__ == "__main__":
+    main()

+ 1 - 0
release

@@ -0,0 +1 @@
+10.26.22.190::release/search-wapage/prod-64/wapage2web/v3.2.89/wapage2web_v3.2.89_Cancel_Tv3.2.88-191206_v3.2.89_20200413-143953_RBL

+ 347 - 0
resin.conf

@@ -0,0 +1,347 @@
+<!--   
+- Resin 3.1 configuration file.
+  -->
+<resin xmlns="http://caucho.com/ns/resin"
+       xmlns:resin="http://caucho.com/ns/resin/core">
+
+  <!-- adds all .jar files under the resin/lib directory -->
+  <class-loader>
+    <tree-loader path="${resin.home}/ext-lib"/>
+    <tree-loader path="${resin.root}/ext-lib"/>
+
+    <tree-loader path="${resin.home}/lib"/>
+    <tree-loader path="${resin.root}/lib"/>
+  </class-loader>
+
+  <!--
+     - Management configuration
+     -
+     - Remote management requires at least one enabled admin user.
+    -->
+  <management path="${resin.root}/admin">
+    <user name="admin" password="password" disable="true"/>
+
+    <resin:if test="${resin.professional}">
+      <deploy-service/>
+      <jmx-service/>
+      <log-service/>
+      <xa-log-service/>
+    </resin:if>
+  </management>
+
+  <!--
+     - Logging configuration for the JDK logging API.
+    -->
+  <log name="" level="info" path="stdout:"
+       timestamp="[%H:%M:%S.%s] {%{thread}} "/>
+
+  <!--
+     - 'info' for production
+     - 'fine' or 'finer' for development and troubleshooting
+    -->
+  <logger name="com.caucho" level="info"/>
+
+  <logger name="com.caucho.java" level="config"/>
+  <logger name="com.caucho.loader" level="config"/>
+
+  <!--
+     - For production sites, change dependency-check-interval to something
+     - like 600s, so it only checks for updates every 10 minutes.
+    -->
+  <dependency-check-interval>2s</dependency-check-interval>
+
+  <!--
+     - SMTP server for sending mail notifications
+    -->
+  <system-property mail.smtp.host="127.0.0.1"/>
+  <system-property mail.smtp.port="25"/>
+
+  <!--
+     - Sets the default character encoding to utf-8
+     -
+     - <character-encoding>utf-8</character-encoding>
+    -->
+
+  <!--
+     - You can change the compiler to "javac", "eclipse" or "internal".
+    -->
+  <javac compiler="internal" args="-source 1.5"/>
+
+  <!-- Security providers.
+     - <security-provider>
+     -    com.sun.net.ssl.internal.ssl.Provider
+     - </security-provider>
+    -->
+
+  <!-- Uncomment to use Resin's XML implementations
+     -
+     - <system-property javax.xml.parsers.DocumentBuilderFactory
+     -                 ="com.caucho.xml.parsers.XmlDocumentBuilderFactory"/>
+     - <system-property javax.xml.parsers.SAXParserFactory
+     -                 ="com.caucho.xml.parsers.XmlSAXParserFactory"/>
+    -->
+
+  <cluster id="app-tier">
+    <!-- sets the content root for the cluster, relative to server.root -->
+    <root-directory>.</root-directory>
+
+    <server-default>
+      <!-- The http port -->
+      <http address="*" port="8080"/>
+
+      <!--
+         - SSL port configuration:
+         -
+         - <http address="*" port="8443">
+         -   <openssl>
+         -     <certificate-file>keys/gryffindor.crt</certificate-file>
+         -     <certificate-key-file>keys/gryffindor.key</certificate-key-file>
+         -     <password>test123</password>
+         -   </openssl>
+         - </http>
+        -->
+
+      <!--
+         - The JVM arguments
+        -->
+      <jvm-arg>-server</jvm-arg>
+      <jvm-arg>-Xmx1536m</jvm-arg>
+      <jvm-arg>-Xms1536m</jvm-arg>
+      <jvm-arg>-Xmn400m</jvm-arg>
+      <jvm-arg>-Xss1m</jvm-arg>
+      <jvm-arg>-XX:PermSize=128m</jvm-arg>
+      <jvm-arg>-XX:MaxPermSize=256m</jvm-arg>
+      <jvm-arg>-Xdebug</jvm-arg>
+      <jvm-arg>-Dcom.sun.management.jmxremote</jvm-arg>
+
+      <!--
+         - Uncomment to enable admin heap dumps
+         - <jvm-arg>-agentlib:resin</jvm-arg>
+        -->
+
+      <!--
+         - arguments for the watchdog process
+        -->
+      <watchdog-jvm-arg>-Dcom.sun.management.jmxremote</watchdog-jvm-arg>
+      <watchdog-port>6600</watchdog-port>
+
+      <!--
+         - Configures the minimum free memory allowed before Resin
+         - will force a restart.
+        -->
+      <memory-free-min>1M</memory-free-min>
+
+      <!-- Maximum number of threads. -->
+      <thread-max>2000</thread-max>
+
+      <!-- Configures the socket timeout -->
+      <socket-timeout>15s</socket-timeout>
+
+      <!-- Configures the keepalive -->
+      <keepalive-max>128</keepalive-max>
+      <keepalive-timeout>15s</keepalive-timeout>
+
+      <!--
+         - If starting bin/resin as root on Unix, specify the user name
+         - and group name for the web server user.
+         -
+         - <user-name>resin</user-name>
+         - <group-name>resin</group-name>
+        -->
+    </server-default>
+
+    <!-- define the servers in the cluster -->
+    <server id="" address="127.0.0.1" port="6800"/>
+
+    <!--
+       - Configures the persistent store for single-server or clustered
+       - in Resin professional.
+      -->
+    <resin:if test="${resin.professional}">
+      <persistent-store type="cluster">
+        <init path="session"/>
+      </persistent-store>
+    </resin:if>
+
+    <!--
+       - For security, use a different cookie for SSL sessions.
+       - <ssl-session-cookie>SSL_JSESSIONID</ssl-session-cookie>
+      -->
+
+    <!--
+       - Enables the cache (available in Resin Professional) 
+      -->
+    <resin:if test="${resin.professional}">
+      <cache path="cache" memory-size="64M">
+        <!-- Vary header rewriting for IE -->
+        <rewrite-vary-as-private/>
+      </cache>
+    </resin:if>
+
+    <!--
+       - Enables periodic checking of the server status and
+       - check for deadlocks..
+       -
+       - All servers can add <url>s to be checked.
+      -->
+    <resin:if test="${resin.professional}">
+      <ping>
+        <!-- <url>http://localhost:8080/test-ping.jsp</url> -->
+      </ping>
+    </resin:if>
+
+    <!--
+       - Defaults applied to each web-app.
+      -->
+    <web-app-default>
+      <prologue>
+        <!--
+           - Extension library for common jar files.  The ext is safe
+           - even for non-classloader aware jars.  The loaded classes
+           - will be loaded separately for each web-app, i.e. the class
+           - itself will be distinct.
+          -->
+        <class-loader>
+          <tree-loader path="${resin.root}/ext-webapp-lib"/>
+        </class-loader>
+
+        <!--
+           - Enable EL expressions in Servlet and Filter init-param
+          -->
+        <allow-servlet-el/>
+      </prologue>
+      
+      <!--
+         - Sets timeout values for cacheable pages, e.g. static pages.
+        -->
+      <cache-mapping url-pattern="/" expires="5s"/>
+      <cache-mapping url-pattern="*.gif" expires="60s"/>
+      <cache-mapping url-pattern="*.jpg" expires="60s"/>
+      <cache-mapping url-pattern="*.png" expires="60s"/>
+
+      <!--
+         - for security, disable session URLs by default.
+        -->
+      <session-config>
+        <enable-url-rewriting>false</enable-url-rewriting>
+      </session-config>
+
+      <!--
+         - For security, set the HttpOnly flag in cookies.
+         - <cookie-http-only/>
+        -->
+
+      <!--
+         - Some JSP packages have incorrect .tld files.  It's possible to
+         - set validate-taglib-schema to false to work around these packages.
+        -->
+        <jsp>
+          <validate-taglib-schema>true</validate-taglib-schema>
+          <fast-jstl>true</fast-jstl>
+          <fast-jsf>false</fast-jsf>
+        </jsp>
+    </web-app-default>
+
+    <!-- includes the app-default for default web-app behavior -->
+    <resin:import path="${resin.home}/conf/app-default.xml"/>
+
+    <!--
+       - Sample database pool configuration
+       -
+       - The JDBC name is java:comp/env/jdbc/test
+         <database>
+           <jndi-name>jdbc/mysql</jndi-name>
+           <driver type="org.gjt.mm.mysql.Driver">
+             <url>jdbc:mysql://localhost:3306/test</url>
+             <user></user>
+             <password></password>
+            </driver>
+            <prepared-statement-cache-size>8</prepared-statement-cache-size>
+            <max-connections>20</max-connections>
+            <max-idle-time>30s</max-idle-time>
+          </database>
+      -->
+
+    <!--
+       - Default host configuration applied to all virtual hosts.
+      -->
+    <host-default>
+      <!--
+         - With another web server, like Apache, this can be commented out
+         - because the web server will log this information.
+        -->
+      <access-log path="logs/access.log" 
+            format='%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"'
+            rollover-period="1W"/>
+
+      <!-- creates the webapps directory for .war expansion -->
+      <web-app-deploy path="/app/wapage/webfront"/>
+
+      <!-- creates the deploy directory for .ear expansion -->
+      <ear-deploy path="deploy">
+        <ear-default>
+          <ejb-server>
+            <config-directory>WEB-INF</config-directory>
+          </ejb-server>
+        </ear-default>
+      </ear-deploy>
+
+      <!-- creates the deploy directory for .rar expansion -->
+      <resource-deploy path="deploy"/>
+    </host-default>
+
+    <!-- configures a deployment directory for virtual hosts -->
+    <host-deploy path="hosts">
+      <host-default>
+        <resin:import path="host.xml" optional="true"/>
+      </host-default>
+    </host-deploy>
+
+    <!-- configures the default host, matching any host name -->
+    <host id="" root-directory=".">
+      <!--
+         - configures an explicit root web-app matching the
+         - webapp's ROOT
+        -->
+       <web-app id="/" character-encoding='UTF-8' document-directory="/data/project/ROOT" archive-path="/data/project/ROOT.war">
+          <stdout-log path="/data/log/devlog/stdout.log" rollover-period="1W"/>
+          <stderr-log path="/data/log/devlog/stderr.log" rollover-period='1W'/>
+	  <access-log path="/dev/null" />
+      
+       <jsp>
+          <dependency-check-interval>300s</dependency-check-interval>
+       </jsp>
+
+       </web-app>
+      <web-app-deploy path="/app/wapage/webfront"/>
+
+    </host>
+  </cluster>
+
+  <!--
+     - Configuration for the web-tier/load-balancer
+    -->
+  <resin:if test="${resin.professional}">
+    <cluster id="web-tier">
+      <server-default>
+        <!-- The http port -->
+        <http address="*" port="9080"/>
+      </server-default>
+
+      <server id="web-a" address="127.0.0.1" port="6700"/>
+
+      <cache path="cache" memory-size="64M"/>
+
+      <host id="">
+        <web-app id="/">
+
+           <rewrite-dispatch>
+             <load-balance regexp="" cluster="app-tier"/>
+           </rewrite-dispatch>
+
+        </web-app>
+      </host>
+    </cluster>
+  </resin:if>
+</resin>
+

+ 2 - 0
root

@@ -0,0 +1,2 @@
+1 */1 * * * /bin/sh /cron/root/nginxlog_cut.sh  > /dev/null 2>&1
+

+ 1 - 0
rsyncd.wapage

@@ -0,0 +1 @@
+wapage_123()

+ 31 - 0
supervisord.conf

@@ -0,0 +1,31 @@
+[unix_http_server]
+file=/var/run/supervisor/supervisor.sock   ; (the path to the socket file)
+
+
+[supervisord]
+logfile=/var/log/supervisor/supervisord.log  ; (main log file;default $CWD/supervisord.log)
+logfile_maxbytes=50MB       ; (max main logfile bytes b4 rotation;default 50MB)
+logfile_backups=10          ; (num of main logfile rotation backups;default 10)
+loglevel=info               ; (log level;default info; others: debug,warn,trace)
+pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
+nodaemon=true              ; (start in foreground if true;default false)
+minfds=10240                 ; (min. avail startup file descriptors;default 1024)
+minprocs=2000                ; (min. avail process descriptors;default 200)
+
+[rpcinterface:supervisor]
+supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
+
+[supervisorctl]
+serverurl=unix:///var/run/supervisor/supervisor.sock ; use a unix:// URL  for a unix socket
+
+[program:resin]
+command=/app/soft/resin-pro-3.1.16/bin/httpd.sh
+process_name=%(program_name)s
+environment=JAVA_HOME="/usr/java/default/",JAVA_BIN="/usr/java/default/bin"
+priority=1000
+startsecs=50
+autostart=true
+startretries=3
+autorestart=true
+user=root
+[supervisord]

+ 75 - 0
www.conf

@@ -0,0 +1,75 @@
+server_info off;
+server_tag EWS/1.0.0;
+log_empty_request off;
+
+gzip on;
+gzip_min_length  1k;
+gzip_buffers     4 16k;
+gzip_http_version 1.1;
+gzip_comp_level 7;
+gzip_types       text/plain application/x-javascript text/css application/xml;
+gzip_vary on;
+
+proxy_redirect off ;
+proxy_http_version 1.1;
+proxy_set_header Connection "";
+proxy_set_header   Host   $host;
+proxy_set_header   Referer $http_referer;
+proxy_set_header   Cookie $http_cookie;
+proxy_set_header   X-Real-IP  $remote_addr;
+proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
+proxy_connect_timeout 30;
+proxy_send_timeout 30;
+proxy_read_timeout 60;
+proxy_buffer_size 512k;
+proxy_buffers 8 512k;
+proxy_busy_buffers_size 512k;
+proxy_temp_file_write_size 512k;
+proxy_next_upstream error timeout http_503;
+
+server
+{
+	listen              80;
+	server_name    0.0.0.0;
+	#charset GB2312;
+
+	location ~ /nginx_status {
+		stub_status on;
+		access_log off;
+		allow 10.0.0.0/8;
+		allow 192.168.0.0/16;
+		deny all;
+	}
+
+	location ~ /cache {
+		proxy_pass   http://backend;
+		allow 10.0.0.0/8;
+		allow 192.168.0.0/16;
+		deny all;
+	}
+
+	if ($http_cookie ~* ".*uid=(.*?);.*$")
+	{
+		set $uid $1;
+	}
+
+	if ($request_uri ~* ".*wver=(\w*)")
+	{
+        	set $mid $1;
+	}
+
+	location ~* \.(css|css\?.*|js|js\?.*|gif|jpg|jpg\?.*|jpeg|png|ico)$ {
+        	proxy_cache easou;
+        	proxy_cache_valid 200 10m;
+          proxy_pass   http://backend;
+          access_log off;
+}
+
+	location / {
+		proxy_pass   http://backend;
+		}
+}
+
+log_format i.easou.com  'v1{]i.easou.com{]$request{]$upstream_http_esid{]$year$month$day $hour$minute$second{]$status{]-{]$request_time_msec{]$body_bytes_sent{]$bytes_sent{]$remote_addr{]$http_x_forwarded_for{]$http_referer{]$sent_http_mobile{]$http_user_agent{]_$mid{]$uid{]$http_via{]v1';
+access_log /log/nginx/visit/access.log i.easou.com;
+include vhosts/www/hostlist.conf;