查看PHP-FPM内存占用

1、查看php-fpm进程数量

ps -ef |grep "php-fpm"|grep "pool"|wc -l

2、查看每个php-fpm进程占用内存

ps -ylC php-fpm --sort:rss

3、查看php-fpm平均内存占用

ps --no-headers -o "rss,cmd" -C php-fpm | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }'

4、查看单个php-fpm进程消耗内存明细

pmap $(pgrep php-fpm) | less

用nginx为yapi做反向代理(二级目录)

通过nginx做为反向代理,将yapi反向代理到二级目录上。

需要通过再次代理来实现。

nginx配置文件如下:

server {
    listen       80;
    server_name  yourdomain.com;

    location /yapi_forward/ {
        proxy_pass http://127.0.0.1:3000/;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_http_version 1.1;
        proxy_set_header Accept-Encoding 'gzip';
        gunzip on;
    }

    location /yapi/ {
        proxy_pass http://yourdomain.com/yapi_forward/;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_http_version 1.1;
        proxy_set_header Accept-Encoding "";
        sub_filter '"/prd' '"/yapi/prd';
        sub_filter '"/iconfont' '"/yapi/iconfont';
        sub_filter '"/image' '"/yapi/image';
        sub_filter '"/api' '"/yapi/api';
        sub_filter '"/user' '"/yapi/user';
        sub_filter '"/group' '"/yapi/group';
        sub_filter '"/project' '"/yapi/project';   
        sub_filter '"/mock' '"/yapi/mock';
        sub_filter 'path:"/' 'path:"/yapi/';
        sub_filter 'to:"/' 'to:"/yapi/';
        sub_filter 'history.push("/' 'history.push("/yapi/';
        sub_filter_types *;
        sub_filter_once off;
    }
}

精确调整Mac鼠标灵敏度

Mac的“偏好设置”中可以按一定量来设置鼠标灵敏度,但是如果想要更精确的设置鼠标灵敏度,就需要用到下面的命令:

1、查询当前鼠标灵敏度

defaults read -g com.apple.mouse.scaling

2、设置鼠标灵敏度

defaults write -g com.apple.mouse.scaling 0.35

重启一下你的Mac,搞定!

用一行命令kill掉指定id号的进程

ps -ef | grep process_name_segment | grep -v grep | awk '{print $2}' | xargs kill -9

命令说明:

ps -ef
# 列出进程信息
grep process_name_segment
# 在进程信息中找到需要杀死的进程命令名
grep -v grep
# 在进程信息中剔除带 grep 的信息(也就是剔除 grep 命令的进程,避免误删)
awk '{print $2}'
# 提取字符串行内容的第2个字段,也就是当前示例的进程号
xargs kill -9
# 将进程号作为参数传递给kill -9这个命令

解决GmSSL报错找不到libssl.so.1.1的错误

按照文档手册安装好国密库GmSSL之后,执行命令:

gmssl version

报错:

gmssl: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory

解决方法如下:

添加两条软连接:

ln -s /usr/local/lib64/libssl.so.1.1 /usr/lib64/libssl.so.1.1
ln -s /usr/local/lib64/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1

再次运行命令,就OK啦:

GmSSL 2.5.4 - OpenSSL 1.1.0d  19 Jun 2019

JavaScript简单的防抖函数

直接上代码:

function debounce(fn, time) {
    return function(args) {
        let that = this
        clearTimeout(fn.tid)
        fn.tid = setTimeout(() => {
            fn.call(that, args)
        }, time);
    }
}

树莓派旋转显示及触摸的方法

HDMI显示器输出:

display_rotate = 0
display_rotate = 1
display_rotate = 2
display_rotate = 3

官方原厂触摸屏输出:

lcd_rotate = 0 //不旋转
lcd_rotate = 1 //旋转90度
lcd_rotate = 2 //旋转180
lcd_rotate = 3 //旋转270