瀏覽代碼

init project

yangxg 2 年之前
父節點
當前提交
e9f90dbb7c
共有 6 個文件被更改,包括 323 次插入1 次删除
  1. 31 1
      Dockerfile
  2. 21 0
      entrypoint.sh
  3. 125 0
      log_clear.sh
  4. 132 0
      nginx.conf
  5. 13 0
      nginx.ini
  6. 1 0
      root

+ 31 - 1
Dockerfile

@@ -1 +1,31 @@
-FROM nginx
+FROM hub.evbj.easou.com/dev/centos:7.9.2009
+
+LABEL author="robert[robert_du@easou.cn]"
+
+ENV LANG en_US.UTF-8
+ENV TZ=Asia/Shanghai
+ENV JAVA_HOME /usr/java/jdk1.8.0_271
+
+COPY entrypoint.sh /usr/bin/entrypoint.sh
+
+#install jdk8 & resin4
+
+RUN yum install -y wget rsync epel-release lsof crontabs vim psmisc nginx\
+    && /usr/sbin/groupadd -g 18001 book ;useradd -s /bin/bash  -g book -u 18001 book \
+    && yum install -y supervisor \
+    && mkdir -p /usr/java  /app/soft /cron/root \
+    && curl -O http://10.26.22.185:9000/psop/soft/jdk1.8.0_271.tar.gz \
+    && tar -xf jdk1.8.0_271.tar.gz -C /usr/java/ \
+    && rm -f jdk1.8.0_271.tar.gz \
+    && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \
+    && chmod +x /usr/bin/entrypoint.sh
+RUN chmod -R go+rwx /var/lib/nginx
+COPY root /var/spool/cron/root
+COPY log_clear.sh /cron/root/log_clear.sh
+ADD nginx.conf /etc/nginx/nginx.conf
+RUN echo "daemon off;" >> /etc/nginx/nginx.conf
+COPY nginx.ini /etc/supervisord.d/nginx.ini
+
+#start resin
+ENTRYPOINT ["entrypoint.sh"]
+CMD ["supervisord"]

+ 21 - 0
entrypoint.sh

@@ -0,0 +1,21 @@
+#!/bin/bash
+
+set -e
+set -o pipefail
+
+chmod 600 /var/spool/cron/root
+sed -i -e '/pam_loginuid.so/s/^/#/' /etc/pam.d/crond
+mkdir -p /log/resin-books/search /log/cron/ /home/book/preps/.java/.userPrefs
+rm -rf /app/soft/resin-4.0.65/log/jvm-app-0.log
+touch /home/book/preps/.java/.userPrefs/.user.lock.book
+touch /home/book/preps/.java/.userPrefs/.userRootModFile.book
+chown book:book -R  /data /app/soft/ /home/book/preps /log/
+
+echo 'export JAVA_HOME=/usr/java/jdk1.8.0_271' >> /etc/profile
+echo 'export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib' >> /etc/profile
+echo 'export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOME/bin' >> /etc/profile
+echo "ulimit -n 65535" >> /etc/profile
+echo "ulimit -u 65535" >> /etc/profile
+source /etc/profile
+
+exec "$@"

+ 125 - 0
log_clear.sh

@@ -0,0 +1,125 @@
+#!/bin/bash
+#Hostname=`hostname|awk -F '.' '{print $1}'`
+Date=`date -d "-1 day" +%F`
+Date1=`date -d "-6 day" +%F`
+AccessDIR=/data1/log/access
+IndexDIR=/data1/log/index
+DevlogDIR=/data1/log/devlog
+
+# access log path
+DIR1=/data/log/other
+
+# index log path
+DIR2=/data/log/index
+
+# devlog log path
+DIR3=/data/log/devlog
+
+#check dir
+function check_access(){
+   if [ ! -d $AccessDIR ]
+   then
+      mkdir -p $AccessDIR
+   fi
+}
+
+function check_index(){
+   if [ ! -d $IndexDIR ]
+   then 
+       mkdir -p $IndexDIR
+   fi
+}
+
+function check_devlog(){
+   if [ ! -d $DevlogDIR ]
+   then
+       mkdir -p $DevlogDIR
+   fi
+}
+
+function accsess(){
+   check_access
+   if [ $? -eq 0 ]
+   then 
+      cd $DIR1
+      cp access_log.$Date* $AccessDIR
+   fi
+}
+
+function index(){
+   check_index
+   if [ $? -eq 0 ]
+   then
+      cd $DIR2
+      cp chapterIndex.log.$Date $IndexDIR
+   fi
+}
+
+function devlog(){
+   check_devlog
+   if [ $? -eq 0 ]
+   then
+      cd $DIR3
+      cp idfaLog.log.$Date $DevlogDIR
+      cp idfaSuccessLog.log.$Date $DevlogDIR
+   fi
+}
+
+function remove_access(){
+    accsess
+    if [ $? -eq 0 ]
+    then
+       cd $DIR1
+       rm -f access_log.$Date*
+    fi
+}
+
+function remove_index(){
+    index
+    if [ $? -eq 0 ]
+    then 
+       cd $DIR2
+       rm -f chapterIndex.log.$Date
+    fi
+}
+
+function remove_devlog(){
+    devlog
+    if [ $? -eq 0 ]
+    then
+       cd $DIR3
+       rm -f idfaLog.log.$Date idfaSuccessLog.log.$Date
+    fi
+}
+
+function remove_log(){
+   remove_access
+   if [ $? -eq 0 ]
+   then 
+      cd $AccessDIR
+      find /data1/log/access/ -type f -name "access_log.*" -mtime +6|xargs rm -f
+   fi
+   remove_index
+   if [ $? -eq 0 ]
+   then 
+      cd $IndexDIR
+      rm -f chapterIndex.log.$Date1 
+   fi
+   remove_devlog
+   if [ $? -eq 0 ]
+   then
+      cd $DevlogDIR
+      find /data1/log/devlog/ -type f -name "*.log.*" -mtime +30|xargs rm -f
+  fi
+}
+
+remove_log
+
+find $DIR1 -mtime +7 -name "*.log.*" -exec rm -rf {} \;
+find $DIR1/rec -mtime +7 -name "*.log.*" -exec rm -rf {} \;
+find /data/log/devlog -mtime +7 -name "*.log.*" -exec rm -rf {} \;
+find /data/log/bookincharge -mtime +7 -name "*.log.*" -exec rm -rf {} \;
+find /data/log/cmread -mtime +7 -name "*.log.*" -exec rm -rf {} \;
+find /data/log/novelweb -mtime +7 -name "*.log.*" -exec rm -rf {} \;
+find /data/log/devlog/bookShelf -mtime +1 -name "*.log*" -exec rm -rf {} \;
+find /data/log/perf/ -type f -name "perf.log.*" -mtime +6|xargs rm -f

+ 132 - 0
nginx.conf

@@ -0,0 +1,132 @@
+#user  nobody;
+user root;
+worker_processes  4;
+
+error_log  /data/logs/error.log;
+#error_log  logs/error.log  notice;
+#error_log  logs/error.log  info;
+
+#pid        logs/nginx.pid;
+
+events {
+    worker_connections  1024;
+}
+
+
+http {
+    include       mime.types;
+    default_type  application/octet-stream;
+
+    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
+    #                  '$status $body_bytes_sent "$http_referer" '
+    #                  '"$http_user_agent" "$http_x_forwarded_for"';
+
+    access_log  /data/logs/access.log  main;
+
+    sendfile        on;
+    #tcp_nopush     on;
+
+    #keepalive_timeout  0;
+    #keepalive_timeout  65;
+
+    gzip  on; # 开启gzip
+    gzip_disable "msie6"; #IE6 不适用gzip
+    gzip_vary on; # 设置为on 会在Header里增加 ”Vary:Accept-Encodng“
+    gzip_proxied any:# 代理数据结果得压缩
+    gzip_comp_level 6; # gzip压缩比( 1-9 ),越小压缩效果越差,但是越大处理效果越慢,所以一般取中间值
+    gzip_buffers 18 8k; # 获取多少内存用于缓存压缩结果
+    gzip_http_version 1.1; # 识别http协议版本
+    gzip_min_length 1k; #设置允许压缩得页面最小字节数,超过1k得文件会被压缩
+    gzip_types application/javascipt text/css; # 对特定得MIME类型生效,js和css文件会被压缩
+
+    include /usr/local/nginx/vhosts/*;
+
+    server {
+        listen       80;
+        server_name  localhost;
+
+        #charset koi8-r;
+
+        #access_log  logs/host.access.log  main;
+
+        location / {
+            root   html;
+            index  index.html index.htm;
+        }
+
+
+        location /images/ {
+            root   /data/;
+            autoindex on;
+        }
+
+        #error_page  404              /404.html;
+
+        # redirect server error pages to the static page /50x.html
+        #
+        error_page   500 502 503 504  /50x.html;
+        location = /50x.html {
+            root   html;
+        }
+
+        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
+        #
+        #location ~ \.php$ {
+        #    proxy_pass   http://127.0.0.1;
+        #}
+
+        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
+        #
+        #location ~ \.php$ {
+        #    root           html;
+        #    fastcgi_pass   127.0.0.1:9000;
+        #    fastcgi_index  index.php;
+        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
+        #    include        fastcgi_params;
+        #}
+
+        # deny access to .htaccess files, if Apache's document root
+        # concurs with nginx's one
+        #
+        #location ~ /\.ht {
+        #    deny  all;
+        #}
+    }
+
+
+    # another virtual host using mix of IP-, name-, and port-based configuration
+    #
+    #server {
+    #    listen       8000;
+    #    listen       somename:8080;
+    #    server_name  somename  alias  another.alias;
+
+    #    location / {
+    #        root   html;
+    #        index  index.html index.htm;
+    #    }
+    #}
+
+
+    # HTTPS server
+    #
+    #server {
+    #    listen       443 ssl;
+    #    server_name  localhost;
+
+    #    ssl_certificate      cert.pem;
+    #    ssl_certificate_key  cert.key;
+
+    #    ssl_session_cache    shared:SSL:1m;
+    #    ssl_session_timeout  5m;
+
+    #    ssl_ciphers  HIGH:!aNULL:!MD5;
+    #    ssl_prefer_server_ciphers  on;
+
+    #    location / {
+    #        root   html;
+    #        index  index.html index.htm;
+    #    }
+    #}
+
+}

+ 13 - 0
nginx.ini

@@ -0,0 +1,13 @@
+[supervisord]
+nodaemon=true
+
+[program:nginx]
+command=nginx -c /etc/nginx/nginx.conf  -g 'daemon off;'
+process_name=%(program_name)s_%(process_num)02d
+numprocs=1
+autostart=true
+autorestart=false
+startsecs=0
+redirect_stderr=true
+stdout_logfile=/dev/stdout
+stdout_logfile_maxbytes=0

+ 1 - 0
root

@@ -0,0 +1 @@
+01 02 * * * sh /cron/root/log_clear.sh >/dev/null 2>&1