#287 常见 Web 缓存服务
WebDev 缓存 2019-01-06Apache,Nginx 都有缓存功能,再加上 Redis 做动态数据的缓存,再加上 CDN,所以我还没有用过专门的缓存服务。
但是这些服务真是大名鼎鼎,即便不用,我也可以先列出来做个简单的了解。
coding in a complicated world
Apache,Nginx 都有缓存功能,再加上 Redis 做动态数据的缓存,再加上 CDN,所以我还没有用过专门的缓存服务。
但是这些服务真是大名鼎鼎,即便不用,我也可以先列出来做个简单的了解。
usage: git submodule [--quiet] [--cached]
or: git submodule [--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [--] <repository> [<path>]
or: git submodule [--quiet] status [--cached] [--recursive] [--] [<path>...]
or: git submodule [--quiet] init [--] [<path>...]
or: git submodule [--quiet] deinit [-f|--force] (--all| [--] <path>...)
or: git submodule [--quiet] update [--init [--filter=<filter-spec>]] [--remote] [-N|--no-fetch] [-f|--force] [--checkout|--merge|--rebase] [--[no-]recommend-shallow] [--reference <repository>] [--recursive] [--[no-]single-branch] [--] [<path>...]
or: git submodule [--quiet] set-branch (--default|--branch <branch>) [--] <path>
or: git submodule [--quiet] set-url [--] <path> <newurl>
or: git submodule [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]
or: git submodule [--quiet] foreach [--recursive] <command>
or: git submodule [--quiet] sync [--recursive] [--] [<path>...]
or: git submodule [--quiet] absorbgitdirs [--] [<path>...]
.gitmodules
[submodule "<moduleName>"]
path = <moduleDir>
url = <repoAddr>
.git/config 中有相近的 section:
[submodule "<moduleName>"]
active = true
url = <repoAddr>
.git 目录在 .git/modules/<moduleName>
参考:https://stackoverflow.com/questions/3796927/how-to-git-clone-including-submodules
git clone --recurse-submodules -j8 github.com:shouce/shouce.git # 2.13+
git clone --recursive -j8 github.com:shouce/shouce.git # 1.6.5+
-j 表示子模块并发操作,每次 n 个子模块。
针对更老的版本或者以存在的库:
git clone github.com:shouce/shouce.git
cd shouce
git submodule update --init --recursive
发现一个 clone 参数 --[no-]shallow-submodules,可以使每个子模块仓库的克隆 deepth 为 1,应该是用得上的。
可能是克隆的时候没有克隆子仓库,也可能是后面添加进来的子仓库。
$ git submodule init
Submodule '<moduleName>' (<repoAddr>) registered for path '<moduleDir>'
$ git submodule update
Cloning into '<moduleFullPath>'...
Submodule path '<moduleDir>': checked out '<commitID>'
或者二合一:
git submodule update --init --recursive
后面有更新就进入子模块 git pull。
git submodule add -b dev --name devtools gitee.com:catroll/devtools tools/dev
# [submodule "devtools"]
# path = tools/dev
# url = gitee.com:catroll/devtools
# branch = dev
$ git submodule deinit <moduleDir>
Cleared directory '<moduleDir>'
Submodule '<moduleName>' (<remoteAddr>) unregistered for path '<moduleDir>'
作用:
这个操作之后:git status 没有任何变化,.gitmodule 还保留着。
然后:
# curl: (35) SSL connect error
# StackOverflow: You are using a very old version of curl.
# yum upgrade curl
# 安装 pyenv
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
# 环境变量
PYENV_ROOT="$HOME/.pyenv"
PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
# 可用版本列表
pyenv install -l
# 使用国内 Python 镜像,相当于给 pyenv 加速
wget https://mirrors.sohu.com/python/3.6.7/Python-3.6.7.tar.xz -P ~/.pyenv/cache/
# 安装(优先使用缓存目录中的文件,会检查缓存校验码是否正确)
pyenv install 3.6.7
假定:
/path/to/project/python main.py早上 01:15 执行某某定时任务:
15 1 * * * /bin/bash /path/to/project/cron.sh
cron.sh#!/bin/bash
# 环境变量
PYENV_ROOT="$HOME/.pyenv"
PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
cd /path/to/project/
# 创建并激活虚拟环境,安装依赖
# $PYENV_ROOT/versions/3.6.7/envs/tasks/
pyenv virtualenv 3.6.7 tasks
if [ $? -ne 0 ]; then
pyenv activate tasks
pip install -r requirements.txt
else
pyenv activate tasks
fi
# 运行脚本
python main.py
#!/bin/bash
# 环境变量
PYENV_ROOT="$HOME/.pyenv"
PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
cd /path/to/project/
# 选择 Python 版本
pyenv local 3.6.7
pip show pipenv > /dev/null
if [ $? -ne 0 ]; then
# 安装 pipenv
pip install pipenv
# 创建虚拟环境,安装依赖
pipenv install
fi
# 运行脚本
pipenv run python main.py
这套方案名气比较大,了解看看。
方便资产统计
HTTP/2 都出来三年半了,还没有一个好用的 Python 客户端库,真是的。
之前只有一个 50G 存储,后来磁盘空间总不够,就把占空间比较大的 Projects 目录(用户主目录下)移出来,弄了一个独立的 50G 盘。
过了段时间,又隔三差五提醒我空间不够了,baobab 清理了,可以删除的东西一删,多出几 GB 来。
但是看结果,还是扩容一下,一了百了。
一个关于 PHP openssl 函数的小实验