Browse Source

Merge branch 'master' of ssh://git.dever.cc:10022/python/dm

rabin 6 years ago
parent
commit
c35ce04f3f

+ 8 - 8
container/conf/web/nginx/conf.d/domain.conf

@@ -8,7 +8,7 @@ server {
 
     charset $charset;
 
-    set $rootdir /www/jiaoyoucms;
+    set $rootdir /www/jy/public;
     root $rootdir;
     index index.php index.html;
 
@@ -22,7 +22,7 @@ server {
         return 404;
     }
 
-    if ( $request_uri ~* ^/(data\/|public\/|assets\/|static\/|crossdomain\.xml|index\.php|favicon\.ico) ) {
+    if ( $request_uri ~* ^/(doc\/|public\/|upload\/|assets\/|static\/|crossdomain\.xml|index\.php|favicon\.ico) ) {
         set $rewrite no;
     }
 
@@ -31,20 +31,20 @@ server {
         rewrite ^/(.*) /index.php/$1 last;
     }
 
-    location ~ /(data\/|public\/|assets\/|static\/|crossdomain\.xml)
+    location ~ /(doc\/|upload\/|public\/|assets\/|static\/|crossdomain\.xml)
     {
         try_files $uri $uri/ /index.html;
     }
 
     location /doc/ {
-    	alias /usr/share/doc/;
-		autoindex on;
-		allow 127.0.0.1;
-		allow ::1;
-		deny all;
+		try_files $uri $uri/ /index.html;
     }
 
     location ~ ^(.*)$ {
+        #add_header Access-Control-Allow-Origin http://192.168.0.109:8080;
+        #add_header Access-Control-Allow-Headers X-Requested-With;
+       # add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
+        #add_header Access-Control-Allow-Credentials true;
         fastcgi_split_path_info ^(.+\.php)(/.+)$;
         # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
 

+ 30 - 5
container/conf/web/nginx/conf.d/site.conf

@@ -1,15 +1,39 @@
 server {
     server_name localhost;
     listen 80 default_server;
+    #listen 443 ssl;
+    #ssl_certificate /usr/local/openresty/nginx/conf/conf.d/ssl/mapi.jstyle.cn.pem;
+    #ssl_certificate_key /usr/local/openresty/nginx/conf/conf.d/ssl/mapi.jstyle.cn.key;
 
     autoindex on;
 
-    set $charset utf-8;
+    gzip on;
+    gzip_min_length 1k;
+    gzip_comp_level 2;
+    gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
+    gzip_vary on;
+    gzip_disable "MSIE [1-6]\.";
 
+    location ~* ^.+\.(ico|gif|jpg|jpeg|png)$ {
+            add_header Access-Control-Allow-Origin *;
+            add_header Access-Control-Allow-Headers X-Requested-With;
+            add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
+            access_log off;
+            expires 30d;
+    }
+    location ~* ^.+\.(css|js|txt|xml|swf|wav)$ {
+            access_log off;
+            expires 24h;
+    }
+    location ~* ^.+\.(eot|ttf|otf|woff|svg)$ {
+            access_log off;
+            expires max;
+    }
+
+    set $charset utf-8;
     charset $charset;
 
     set $rootdir /www;
-
     if ( $request_uri ~* ^/(dever_package\/manage|dever_package\/ui|dever_package\/script) ) {
         set $rootdir /share/lib/php;
     }
@@ -24,8 +48,8 @@ server {
     if ( $request_uri ~* /system/wechat ) {
             rewrite ^/system/wechat /system/index.php?m=payment&a=wechat_notify last;
     }
-    if ( $request_uri ~* /grow/pay/notify ) {
-            rewrite ^/grow/pay/notify/([0-9+]) /grow/pay/index.php?l=api.notify&account_id=$1 last;
+    if ( $request_uri ~* /pay/pay/notify ) {
+            rewrite ^/pay/pay/notify/([0-9+]) /pay/pay/index.php?l=api.notify&account_id=$1 last;
     }
     location / {
                 # First attempt to serve request as file, then
@@ -41,7 +65,8 @@ server {
         # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini (No settings!)
 
         # With php-cgi alone:
-        fastcgi_pass web-php7:9000;
+        fastcgi_pass web-php7_swoole:9000;
+        #fastcgi_pass web-php7:9000;
         #fastcgi_pass web-php5:9000;
         # With php-fpm:
         #fastcgi_pass unix:/var/run/php7-fpm.sock;

+ 1 - 1
container/conf/web/php5/php.ini

@@ -1447,7 +1447,7 @@ session.save_handler = files
 ; where MODE is the octal representation of the mode. Note that this
 ; does not overwrite the process's umask.
 ; http://php.net/session.save-path
-;session.save_path = "/tmp"
+session.save_path = "/tmp"
 
 ; Whether to use strict session mode.
 ; Strict session mode does not accept uninitialized session ID and regenerate

+ 1 - 0
container/conf/web/php7/conf.d/00_fileinfo.ini

@@ -0,0 +1 @@
+extension=fileinfo.so

+ 1 - 0
container/conf/web/php7/conf.d/00_opcache.ini

@@ -0,0 +1 @@
+zend_extension=opcache.so

+ 1 - 0
container/conf/web/php7/conf.d/00_posix.ini

@@ -0,0 +1 @@
+extension=posix.so

+ 1 - 0
container/conf/web/php7/conf.d/00_tokenizer.ini

@@ -0,0 +1 @@
+extension=tokenizer.so

+ 1 - 0
container/conf/web/php7/conf.d/10_redis.ini

@@ -0,0 +1 @@
+extension=redis.so

+ 1 - 0
container/conf/web/php7/conf.d/imagick.ini

@@ -0,0 +1 @@
+extension=imagick.so

+ 15 - 15
container/conf/web/php7/php.ini

@@ -1323,7 +1323,7 @@ bcmath.scale = 0
 
 [Session]
 ; Handler used to store/retrieve data.
-; http://php.net/session.save-handler
+; http://php.net/session.save-handler redis tcp://192.168.1.10:6379?auth=password
 session.save_handler = files
 
 ; Argument passed to save_handler.  In the case of files, this is the path
@@ -1353,7 +1353,7 @@ session.save_handler = files
 ; where MODE is the octal representation of the mode. Note that this
 ; does not overwrite the process's umask.
 ; http://php.net/session.save-path
-;session.save_path = "/tmp"
+session.save_path = "/tmp"
 
 ; Whether to use strict session mode.
 ; Strict session mode does not accept uninitialized session ID and regenerate
@@ -1780,52 +1780,52 @@ ldap.max_links = -1
 
 [opcache]
 ; Determines if Zend OPCache is enabled
-;opcache.enable=1
+opcache.enable=0
 
 ; Determines if Zend OPCache is enabled for the CLI version of PHP
-;opcache.enable_cli=0
+opcache.enable_cli=0
 
 ; The OPcache shared memory storage size.
-;opcache.memory_consumption=128
+opcache.memory_consumption=128
 
 ; The amount of memory for interned strings in Mbytes.
-;opcache.interned_strings_buffer=8
+opcache.interned_strings_buffer=8
 
 ; The maximum number of keys (scripts) in the OPcache hash table.
 ; Only numbers between 200 and 1000000 are allowed.
-;opcache.max_accelerated_files=10000
+opcache.max_accelerated_files=10000
 
 ; The maximum percentage of "wasted" memory until a restart is scheduled.
-;opcache.max_wasted_percentage=5
+opcache.max_wasted_percentage=5
 
 ; When this directive is enabled, the OPcache appends the current working
 ; directory to the script key, thus eliminating possible collisions between
 ; files with the same name (basename). Disabling the directive improves
 ; performance, but may break existing applications.
-;opcache.use_cwd=1
+opcache.use_cwd=0
 
 ; When disabled, you must reset the OPcache manually or restart the
 ; webserver for changes to the filesystem to take effect.
-;opcache.validate_timestamps=1
+opcache.validate_timestamps=1
 
 ; How often (in seconds) to check file timestamps for changes to the shared
 ; memory storage allocation. ("1" means validate once per second, but only
 ; once per request. "0" means always validate)
-;opcache.revalidate_freq=2
+opcache.revalidate_freq=60
 
 ; Enables or disables file search in include_path optimization
-;opcache.revalidate_path=0
+opcache.revalidate_path=0
 
 ; If disabled, all PHPDoc comments are dropped from the code to reduce the
 ; size of the optimized code.
-;opcache.save_comments=1
+opcache.save_comments=0
 
 ; If enabled, a fast shutdown sequence is used for the accelerated code
 ; Depending on the used Memory Manager this may cause some incompatibilities.
-;opcache.fast_shutdown=0
+opcache.fast_shutdown=1
 
 ; Allow file existence override (file_exists, etc.) performance feature.
-;opcache.enable_file_override=0
+;opcache.enable_file_override=1
 
 ; A bitmask, where each bit enables or disables the appropriate OPcache
 ; passes

+ 36 - 0
container/conf/web/smproxy/database.json

@@ -0,0 +1,36 @@
+{
+  "database": {
+    "account": {
+      "root": {
+        "user": "root",
+        "password": "123456"
+      }
+    },
+    "serverInfo": {
+      "server1": {
+        "write": {
+          "host": ["web-mysql"],
+          "port": 3306,
+          "timeout": 2,
+          "account": "root"
+        },
+        "read": {
+          "host": ["web-mysql"],
+          "port": 3306,
+          "timeout": 2,
+          "account": "root"
+        }
+      }
+    },
+    "databases": {
+      "wonderful": {
+        "serverInfo": "server1",
+        "startConns": "swoole_cpu_num()*10",
+        "maxSpareConns": "swoole_cpu_num()*10",
+        "maxSpareExp": 3600,
+        "maxConns": "swoole_cpu_num()*20",
+        "charset": "utf8mb4"
+      }
+    }
+  }
+}

+ 43 - 0
container/conf/web/smproxy/server.json

@@ -0,0 +1,43 @@
+{
+  "server": {
+    "user": "root",
+    "password": "123456",
+    "charset": "utf8mb4",
+    "host": "web-php7_smproxy",
+    "port": "3366",
+    "mode": "SWOOLE_PROCESS",
+    "sock_type": "SWOOLE_SOCK_TCP",
+    "logs": {
+      "open":true,
+      "config": {
+        "system": {
+          "log_path": "ROOT/logs",
+          "log_file": "system.log",
+          "format": "Y/m/d"
+        },
+        "mysql": {
+          "log_path": "ROOT/logs",
+          "log_file": "mysql.log",
+          "format": "Y/m/d"
+        }
+      }
+    },
+    "swoole": {
+      "worker_num": "swoole_cpu_num()",
+      "max_coro_num": 6000,
+      "open_tcp_nodelay": true,
+      "daemonize": true,
+      "heartbeat_check_interval": 60,
+      "heartbeat_idle_time": 600,
+      "reload_async": true,
+      "log_file": "ROOT/logs/swoole.log",
+      "pid_file": "ROOT/logs/pid/server.pid"
+    },
+    "swoole_client_setting": {
+      "package_max_length": 16777215
+    },
+    "swoole_client_sock_setting": {
+      "sock_type": "SWOOLE_SOCK_TCP"
+    }
+  }
+}

+ 1 - 0
install

@@ -46,6 +46,7 @@ if [ "$yumstatus" = 0 ]; then
 else
 	yum install python-gevent
 fi
+#dm run server-redis
 #python $basepath/src/daemon.py &
 
 docker version

+ 18 - 3
src/daemon.py

@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
-# dm_process为key,value为具体指令 如:dm call office-convert_call id=1
+# dm_process为key,value为具体指令 如:call office-convert_call id=1
 import time
 import os
 #import pprint
@@ -21,7 +21,7 @@ def pop(key):
         return popen('redis -a '+password+' lpop ' + key)
 
 def command(process):
-        return process
+        return 'dm ' + process
 
 def popen(command, bg=False):
         string = command
@@ -47,10 +47,25 @@ def process():
                         gevent.sleep(timeSleep)
                         i = 0
 
+# 定时备份
+def backup():
+        r = redis()
+        c = 'dm_process'
+        i = 0
+        while 1:
+                value = r.lpop(c)
+                if value:
+                        g = command(value)
+                        popen(g)
+                i = i+1
+                if i >= 10:
+                        gevent.sleep(timeSleep)
+                        i = 0
+
 def handle():
 	gevent.joinall([
 		gevent.spawn(process),
-		#gevent.spawn(backup),
+		gevent.spawn(backup),
 	])
 
 handle()

+ 37 - 0
src/docker/build/dev/php/smproxy/Dockerfile

@@ -0,0 +1,37 @@
+FROM php:7.2.13-cli-alpine
+
+ENV SMProxy_VERSION 1.2.7
+
+RUN apk add --no-cache --virtual .phpize-deps $PHPIZE_DEPS linux-headers \
+    && pecl install swoole \
+    && docker-php-ext-enable swoole \
+    \
+    # xBring in gettext so we can get `envsubst`, then throw
+    # the rest away. To do this, we need to install `gettext`
+    # then move `envsubst` out of the way so `gettext` can
+    # be deleted completely, then move `envsubst` back.
+    && apk add --no-cache --virtual .gettext gettext \
+    && mv /usr/bin/envsubst /tmp/ \
+    \
+    && runDeps="$( \
+        scanelf --needed --nobanner --format '%n#p' /usr/local/bin/php /usr/local/lib/php/extensions/*/*.so /tmp/envsubst \
+            | tr ',' '\n' \
+            | sort -u \
+            | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
+    )" \
+    && apk add --no-cache --virtual .php-rundeps $runDeps \
+    && apk del .phpize-deps \
+    && apk del .gettext \
+    && mv /tmp/envsubst /usr/local/bin/ \
+    \
+    && cd /usr/local \
+    && wget https://github.com/louislivi/smproxy/releases/download/v$SMProxy_VERSION/smproxy.tar.gz \
+    && tar -zxvf smproxy.tar.gz \
+    && ls -lna
+
+VOLUME /usr/local/smproxy/conf
+VOLUME /usr/local/smproxy/logs
+
+EXPOSE 3366
+
+CMD ["/usr/local/smproxy/SMProxy", "start", "--console"]

+ 5 - 0
src/docker/build/dev/php/swoole/Dockerfile

@@ -0,0 +1,5 @@
+FROM docker.dever.cc/dev/php/v7:latest
+
+MAINTAINER Rabin "https://github.com/shemic"
+
+RUN ./install.sh swoole-4.3.0 swoole libevent-dev,libaio-dev,libmnl-dev

+ 1 - 1
src/docker/build/dev/php/v5/install.sh

@@ -20,5 +20,5 @@ fi
 make
 make install
 echo extension=$2.so > /etc/php5/conf.d/$2.ini
-killall -9 php-fpm5 && php-fpm5 &
+#killall -9 php-fpm5 && php-fpm5 &
 #apk del $lib

+ 1 - 1
src/docker/build/dev/php/v7/Dockerfile

@@ -4,7 +4,7 @@ MAINTAINER Rabin "https://github.com/shemic"
 
 ENV COMPOSER_HOME=/share/lib/php
 
-RUN apk add --no-cache --update curl php7-fpm php7-pear php7-mysqli php7-session php7-pgsql php7-pdo_mysql php7-pdo_pgsql php7-gd php7-curl php7-mcrypt php7-json php7-zlib php7-xml php7-xmlwriter php7-iconv php7-zip php7-phar  php7-openssl php7-dom php7-mbstring php7-simplexml php7-sockets php7-pcntl php7-fileinfo && curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/bin/composer && apk del curl && composer config -g repo.packagist composer https://packagist.phpcomposer.com
+RUN apk add --no-cache --update curl php7-fpm php7-pear php7-mysqli php7-session php7-pgsql php7-pdo_mysql php7-pdo_pgsql php7-gd php7-curl php7-mcrypt php7-json php7-zlib php7-xml php7-xmlwriter php7-iconv php7-zip php7-phar  php7-openssl php7-dom php7-mbstring php7-simplexml php7-sockets php7-pcntl php7-fileinfo  php7-tokenizer php7-opcache php7-redis php7-imagick php7-posix && curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/bin/composer && apk del curl && composer config -g repo.packagist composer https://packagist.phpcomposer.com
 
 #php7-memcached php7-redis 
 

+ 1 - 1
src/docker/build/dev/php/v7/install.sh

@@ -20,5 +20,5 @@ fi
 make
 make install
 echo extension=$2.so > /etc/php7/conf.d/10_$2.ini
-killall -9 php-fpm7 && php-fpm7
+#killall -9 php-fpm7 && php-fpm7
 #apk del $lib

+ 17 - 0
src/docker/build/dm/admin/Dockerfile

@@ -0,0 +1,17 @@
+FROM docker.dever.cc/dev/python:latest
+
+MAINTAINER Rabin "https://github.com/shemic"
+
+ENV ADMIN_HOME=/usr/local/admin
+ENV ADMIN_LIB=/usr/lib/python2.7/site-packages/demeter
+ENV DEMETER_CONF=env
+ENV PATH=$PATH:$ADMIN_HOME
+
+RUN apk add --no-cache --update py-gevent git && \
+	pip install -U git+http://git.dever.cc:3000/python/demeter.git && \
+	git clone http://git.dever.cc:3000/demeter/admin.git $ADMIN_HOME && \
+	chmod -R +x $ADMIN_HOME/*.py
+
+EXPOSE 8011 8012
+
+COPY admin.sh /entrypoint/admin.sh

+ 26 - 0
src/docker/build/dm/admin/admin.sh

@@ -0,0 +1,26 @@
+#!/usr/bin/env sh
+set -e
+start_admin()
+{
+    cd $ADMIN_LIB
+    git pull
+    cd $ADMIN_HOME
+    git reset --hard FETCH_HEAD
+    git pull
+    chmod -R +x $ADMIN_HOME/*.py
+    python install.py
+    process_start admin.py
+    process_start cron.py
+}
+
+stop_admin()
+{
+	process_stop admin.py
+    process_stop cron.py
+}
+
+monit_admin()
+{
+    process_monit admin.py
+    process_monit cron.py
+}

+ 3 - 0
src/docker/build/tool/ffmpeg/Dockerfile

@@ -0,0 +1,3 @@
+FROM jrottenberg/ffmpeg
+
+MAINTAINER Rabin "https://github.com/shemic"

+ 2 - 0
src/docker/build/tool/pan/Dockerfile

@@ -2,4 +2,6 @@ FROM jaegerdocker/pan
 
 MAINTAINER Rabin "https://github.com/shemic"
 
+#https://hub.docker.com/r/jaegerdocker/pan superuser 
+
 RUN chown -R mysql /var/lib/mysql && chgrp -R mysql /var/lib/mysql

+ 8 - 0
src/docker/conf/chengmao.conf

@@ -53,4 +53,12 @@ volumes = {container}web/mall:/root/input,{container}web/mall/doc:/root/output,{
 call = apidoc
 #使用dm call iot-apidoc input=demo&out=output来运行,然后可以在宿主机里使用apidoc命令
 param = -i /root/input/doc -o /root/output -c /root/config
+alias = apidoc
+
+[jy_apidoc]
+image = apidoc
+volumes = {container}web/jiaoyoucms:/root/input,{container}web/jiaoyoucms/public/doc:/root/output,{container}web/jiaoyoucms/public/doc:/root/config
+call = apidoc
+#使用dm call iot-apidoc input=demo&out=output来运行,然后可以在宿主机里使用apidoc命令
+param = -i /root/input/doc -o /root/output -c /root/config
 alias = apidoc

+ 5 - 3
src/docker/conf/daemon.conf

@@ -1,13 +1,13 @@
 [base]
 path = {base}
-default = master,manager
+default = master,manager,operater
 network = overlay_dm
 subnet = 10.0.0.0/255
 
 ;别名注册,使用 dm run daemon-run
 [alias]
 run = master,manager,operater
-add = client,worker
+join = client,worker
 
 [redis]
 ;port = 6379:6379,8888:8888
@@ -54,7 +54,9 @@ volumes = {container}share/lib:/data
 ;操作者,图形界面后台,可以直接访问daemon-manager
 [operater]
 image = admin
-port = 9091:8011,9092:8012
+port = 9091:8087,9092:8088
+volumes = {container}web:/web
+command = admin
 
 ;master、manager、operater、crond为主机开启
 ;client、worker为其他机器开启

+ 8 - 1
src/docker/conf/tool.conf

@@ -52,4 +52,11 @@ volumes = {container}share/sync_client:/data
 image = vsftpd
 port = 20:20,21:21,21100-21110:21100-21110
 volumes = {container}web/files:/home/vsftpd
-environment = FTP_USER=ftpadmin,FTP_PASS=123456
+environment = FTP_USER=ftpadmin,FTP_PASS=123456
+
+[ffmpeg]
+image = ffmpeg
+volumes = {container}web/mc/data:/tmp
+call = ffmpeg
+param = -i /tmp/001.avi -vcodec libx264 -threads 2 -preset fast -crf 28 -y -vf "scale=1920:-1" -acodec libmp3lame -ab 128k /tmp/out.mp4
+alias = ffmpeg

+ 9 - 0
src/docker/conf/web.conf

@@ -30,9 +30,18 @@ alias = php,composer,pecl,apk,/install.sh->phpInstall
 
 [php7]
 #port = 8082:8080
+#image = php7_swoole
+port = 2346:2346,1236:1236,1237:1237,1238:1238
 volumes = {container}web:/www,{container}conf/web/php7:/etc/php7
 alias = php,composer,pecl,apk,/install.sh->phpInstall
 
+[php7_swoole]
+volumes = {container}web:/www,{container}conf/web/php7:/etc/php7
+
+[php7_smproxy]
+port = 3366:3366
+volumes = {container}web:/www,{container}conf/web/php7:/etc/php7,{container}conf/web/smproxy:/usr/local/smproxy/conf,{container}logs/{name}/logs:/usr/local/smproxy/logs
+
 [#nginx]
 #num = 3
 # num和cluster都可以设置有多少个nginx进程,不同的是,cluster仅对ds有效

+ 7 - 1
src/docker/core.conf

@@ -16,6 +16,8 @@ debian				= os/debian
 ;dev
 php5				= dev/php/v5
 php7				= dev/php/v7
+php7_swoole			= dev/php/swoole
+php7_smproxy		= dev/php/smproxy
 java				= dev/java
 java_base			= java/base
 maven				= java/maven
@@ -78,6 +80,7 @@ grafana				= tool/grafana
 pan					= tool/pan
 vsftpd				= tool/vsftpd
 nextcloud           = tool/nextcloud
+ffmpeg				= tool/ffmpeg
 
 ;learn
 learn				= learning
@@ -122,4 +125,7 @@ lvs					= balance/lvs
 nfs					= file/nfs
 btsync				= file/btsync
 rsync				= file/rsync
-lsyncd				= file/lsyncd
+lsyncd				= file/lsyncd
+
+;dm
+admin				= dm/admin

+ 7 - 0
src/shell/webbench

@@ -0,0 +1,7 @@
+#!/usr/bin/env sh
+set -e
+
+for((i=1;i<=1000;i++));  
+do   
+webbench -c 100 -t 10 "http://mapi.jstyle.cn/wonderful/main/?journal.getList&system=2&test={$RANDOM}"
+done

+ 1 - 1
src/tool/php.py

@@ -18,7 +18,7 @@ class Php_Action(object):
 		#http://pecl.php.net
 		# 名称-版本号,so名,依赖包,configure参数
 		'libevent' : ['event-2.3.0', 'event', 'curl-dev,libevent-dev', '']
-		,'swoole' : ['swoole-2.0.10', 'swoole', 'libevent-dev,libaio-dev,libmnl-dev', '']
+		,'swoole' : ['swoole-4.3.0', 'swoole', 'libevent-dev,libaio-dev,libmnl-dev', '']
 		,'mongo' : ['mongodb-1.3.4', 'mongodb', '', '']
 		,'redis' : ['redis-3.1.5RC2', 'redis', '', '']
 		,'memcached' : ['memcached-3.0.4', 'memcached', 'curl-dev,libmemcached-dev,cyrus-sasl-dev', '']