很久没有更新过博客了,最近将逐渐开更
今天记录下我如何调整服务器 php-fpm 的 max_children
ps -ylef --sort:rss
此命令可以查看当前服务器所有的进程以及占用内存,留意 RSS 那列就是占用的内存数。
当做平均一个进程 50MB
我的机器是8G,预留个1G,那大概数量就是 (8-1) * 1024 / 50 = 143
很久没有更新过博客了,最近将逐渐开更
今天记录下我如何调整服务器 php-fpm 的 max_children
ps -ylef --sort:rss
此命令可以查看当前服务器所有的进程以及占用内存,留意 RSS 那列就是占用的内存数。
当做平均一个进程 50MB
我的机器是8G,预留个1G,那大概数量就是 (8-1) * 1024 / 50 = 143
开机后打算继续给项目做压测,发现接口返回了 Malformed UTF-8 characters, possibly incorrectly encoded
,一脸懵逼后发现原来 MySQL 没开,Mark 一下
这个低级问题没想到我还是掉进去了,没想到是一个参数问题
listen.allowed_clients = 127.0.0.1
把 /etc/php/7.2/fpm/pool.d/www.conf 中这行接触注释就好了
为啥突然出现原因不详,先mark
查找 php.ini 路径php -i | grep "Loaded Configuration File"
这次不造轮子,写写文章。
最近想把自己的 blog 整理到 github 上,但由于其中依赖了一些主题以及插件,这时候 git submodule 就能很好的处理这种情况了。
submodule 顾名思义,子模块。在一个项目依赖其他 git 上的模块时就很有用处了。
以我自己这次修改做例子:
我的 typecho 博客 依赖了 主题 typecho_material_theme 和 插件 Links_for_Material_Theme
那写下来就写写整个过程。
/usr/theme
和 /usr/plugins
相关路径去掉(在最底部的4行)开始增加子模块(最后为路径)
cd typecho
git submodule add git@github.com:HanSon/typecho_material_theme.git usr/theme/typecho_material_theme
git submodule add git@github.com:HanSon/Links_for_Material_Theme.git usr/theme/Links
这时候应该能看到开始对两个库 clone 中,查看一下 git status
, 应该能看到修改的有多了两个库,以及 .gitmodules
的修改
git status
然后我们来提交到 github 中
git commit -am "增加子模块"
git push origin master
这时就已经成功提交到 github 上了,我们来看看 github 上是如何显示 submodule 的
可以看到多了两个不一样的图标,点击自动跳转去该仓库的地址(@ 后面代表的是 commit id)
git clone https://github.com/HanSon/my-blog.git
cd my-blog
pull 完发现只剩下文件夹,submodule 并没有内容,需要先初始化 submodule 并且 update
git submodule init
git submodule update
这时候就发现 submodule 的内容已经 pull 下来了!
如果更新了 submodule , project 应该如何跟着更新?
git pull origin master
即可。git submodule foreach git pull origin master
这次给我的博客加上了播放哈林摇的功能 http://hanc.cc
你还可以把上图的 Let's party
拖到书签栏,然后访问你想要摇的网站,点击刚保存的书签进行摇一下。
PS:上面所述为实操后凭记忆记下来的,如有遗漏欢迎补充
这是因为当初的姿势不正确,导致 .git 文件夹为root用户所属
改回来即可
sudo chown -R $(whoami):admin .git
github中删除release/tag只能在命令执行,不能界面点击操作
git tag -d [tag];
git push origin :[tag]
假若需要删除一个 v1.1.1 的release版本
git tag -d v1.1.1;
git push origin :v1.1.1
删除除了master外的本地分支
git branch | grep -v "master" | xargs git branch -D
最近做项目掉进一个深坑,以至于一个小问题烦恼我两天以至于怀疑人生。
新项目需要连接两个mysql数据库,然而却出现无论如何也查询不了第二个数据库的情况。
经历了多次断点调试,google无止境搜索,询问印度阿三无果的情况下,也只能查看源码解决问题了。
最终发现在laravel的ConnectionFactory类的createConnection方法中有这么一段
protected function createConnection($driver, $connection, $database, $prefix = '', array $config = [])
{
if ($this->container->bound($key = "db.connection.{$driver}")) {
return $this->container->make($key, [$connection, $database, $prefix, $config]);
}
switch ($driver) {
case 'mysql':
return new MySqlConnection($connection, $database, $prefix, $config);
case 'pgsql':
return new PostgresConnection($connection, $database, $prefix, $config);
case 'sqlite':
return new SQLiteConnection($connection, $database, $prefix, $config);
case 'sqlsrv':
return new SqlServerConnection($connection, $database, $prefix, $config);
}
throw new InvalidArgumentException("Unsupported driver [$driver]");
}
$this->container->bound($key = "db.connection.{$driver}")
通过driver去跟容器做了绑定,也就是当你有第二个一样driver的数据库时,调用 $this->container->make()
方法也会同样返回第一个绑定的 connection
,这样无论如何也只能查询第一个了。
修改后
if ($this->container->bound($key = "db.connection.{$driver}.{$config['name']}")) {
return $this->container->make($key, [$connection, $database, $prefix, $config]);
}
通过传入connection
自定义的名称,能够避免重复
只可惜我提PR时对方表示5.3不作bug修复,很诧异。。。
在使用elasticsearch时出现了异常,显示SearchPhaseExecutionException[Failed to execute phase [query], all shards failed]
解决方案为curl -XPUT 'localhost:9200/*/_settings' -d ' { "index" : { "number_of_replicas" : 0 } } '