文章

运维笔记

ps -A | grep redis
lsof -p 1024
lsof -i :10079
kill 1024

ps -A列出所有进程,grep redis过滤出含有redis的行;

查出PID为1024的进程情况;

查出端口为10079的进程情况;

退出PID为1024的进程,kill -9 1024为强制停止1024的进程;


git log --author="JmyFilm" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -
git log --format='%aN' | sort -u | while read name; do echo -en "$name\t"; git log --author="$name" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -; done

查看指定用户Git提交行数、删除行数

查看所有用户Git提交行数、删除行数


/etc/systemd/system/__NAME__.service
[Unit]
After=network-online.target

[Service]
ExecStart=__RUNPATH__/__NAME__
WorkingDirectory=__RUNPATH__
StandardOutput=append:__RUNPATH__/run.log
StandardError=append:__RUNPATH__/run.log
ExecReload=/bin/kill -s HUP $MAINPID
Restart=on-failure
User=root

[Install]
WantedBy=multi-user.target

创建进程守护,注意替换__NAME____RUNPATH__


nginx -t
nginx -s reload

Nginx 检查配置文件

Nginx 重新加载配置文件


http {
    upstream backend {
        server 127.0.0.1:2710;
        server 127.0.0.1:2720;
    }

    server {
        listen 80;
        server_name api.domain.com;

        real_ip_header X-Forwarded-For;
        real_ip_recursive on;

        location / {
            proxy_pass http://backend;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
        }
    }
}

Nginx 域名负载均衡反向代理


docker run -d --name MySQL -p 3306:3306 -e MYSQL_ROOT_PASSWORD=121212 mysql
docker run -d --name Redis -p 6379:6379 redis

Docker 运行 MySQL

Docker 运行 Redis


boo.com {
        rewrite * /api{path}
        reverse_proxy https://foo.com {
                header_up Host {upstream_hostport}
        }
}

Caddy使boo.com/的请求代理到foo.com/api/


foo.com {
    root *  /xxx/xxx/html
    encode zstd gzip
    route {
        reverse_proxy /api localhost:2781
        try_files {path} /index.html
        file_server
    }
}

Caddy部署Vue等单页面程序可参考的配置