git release功能

git release功能
命令行:

git tag -a v3.0 -m “这是4.0版本”
git push origin v3.0
//git tag -a 标签名称 -m “说明”
//git push origin 标签名称
删除tag

git tag -d v1.1 //删除本地tag

git push origin :v1.1//删除远程tag
//也可以这样
git push origin –delete tag V1.1

发表在 git | 留下评论

安装 PHP7.2 ZTS

1、安装(当时7.1、7.2怎么都装不上pthreads扩展)
brew install php@7.0 –build-from-source

2、brew edit php70
args = %W[
--prefix=#{prefix}
--enable-maintainer-zts
--with-tsrm-pthreads

3、重新安装
brew reinstall php@7.0 --build-from-source

PHP 7.0.30 (cli) (built: May 5 2018 18:30:50) ( ZTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.30, Copyright (c) 1999-2017, by Zend Technologies

看到ZTS说明就是安装成功了

4、安装pthreads扩展(由于最新版本已经不支持7.2以下的了,这个是master之前的一个发行版本)
wget https://github.com/krakjoe/pthreads/archive/v3.1.6.tar.gz
tar -zxvf v3.1.6.tar.gz
cd pthreads
phpize
./configure
make
make install (may need sudo)
将生成的.so文件配置到php.ini

php --ri pthreads

pthreads

Version => 3.1.6

注: 这里其实踩了很多坑,安装前后花费了一天多的时间

5、测试脚本

start();
}

foreach($pool as $worker) {
    $worker->join();
}
发表在 php | 留下评论

brew 切换源

https://blog.csdn.net/lwplwf/article/details/79097565

发表在 小技巧 | 留下评论

git 临时提交

临时提交

git stash save ‘临时修改’
git stash list
git stash pop 标示
git stash clear

发表在 git | 留下评论

免费Mysql数据库

https://www.freemysqlhosting.net 提供5M空间

发表在 mysql | 留下评论

php-fpm 优化相关

https://www.cnblogs.com/tangchuanyang/p/6201859.html

https://www.cnblogs.com/JohnABC/p/4531107.html

http://www.4wei.cn/archives/1002061

http://www.liuxos.com/post/56/php-fpm%E4%B8%8Emysql%E9%95%BF%E8%BF%9E%E6%8E%A5.html

发表在 php-fpm | 留下评论

CentOS 经常主动断开解决办法

a. 将 ClientAliveInterval 0和ClientAliveCountMax 3的注释符号去掉;
b. 将ClientAliveInterval对应的0改成60,ClientAliveInterval指定了服务器端向客户端请求消息的时间间隔,默认是0,不发送。而ClientAliveInterval60表示每分钟发送一次,然后客户端响应,这样就保持长连接了。
c.ClientAliveCountMax,使用默认值3即可。ClientAliveCountMax表示服务器发出请求后客户端没有响应的次数达到一定值,就自动断开。正常情况下,客户端不会不响应。
d. 执行service sshd restart 或 /etc/init.d/sshdrestart,使改过的配置生效。

发表在 linux | 留下评论

git 更新单个文件

http://blog.csdn.net/peterli_xue/article/details/78192963

发表在 git | 留下评论

迭代器模式

printMenu();

addItem('煎饼1', '这是煎饼1', true, 5.5);
        $this->addItem('煎饼2', '这是煎饼2', true, 6.5);
        $this->addItem('煎饼3', '这是煎饼3', true, 7.5);
    }

    protected function addItem($name, $description, $vegetarian, $price) {
        $menu_item = new MenuItem($name, $description, $vegetarian, $price);
        $this->_menu_items[] = $menu_item;
    }

    public function getIterator() {
        yield new MenuItem('煎饼1', '这是煎饼1', true, 5.5);
        yield new MenuItem('煎饼2', '这是煎饼2', true, 6.5);
        yield new MenuItem('煎饼3', '这是煎饼3', true, 7.5);
    }

    public function createIterator() {
        return new PancakeMenuIterator($this->_menu_items);
    }
}
addItem('宫保鸡丁', '宫保鸡丁描述', true, 12);
        $this->addItem('鱼香肉丝', '鱼香肉丝描述', true, 16);
        $this->addItem('火爆腰花', '火爆腰花描述', true, 35);
    }

    protected function addItem($name, $description, $vegetarian, $price) {
        $menu_item = new MenuItem($name, $description, $vegetarian, $price);
        $this->_menu_items[] = $menu_item;
    }

    public function createIterator() {
        return new DinerMenuIterator($this->_menu_items);
    }

}
_menu_items = $menu_items;
    }

    public function hasNext() {
        return isset($this->_menu_items[$this->_position]);
    }

    public function next() {
        $current_item = $this->_menu_items[$this->_position] ?? null;

        $this->_position ++;

        return $current_item;
    }

}
_menu_items = $menu_items;
    }

    public function hasNext() {
        return isset($this->_menu_items[$this->_position]);
    }

    public function next() {
        $current_item = $this->_menu_items[$this->_position] ?? null;

        $this->_position ++;

        return $current_item;
    }

}
_name = $name;
        $this->_description = $description;
        $this->_vegetarian = $vegetarian;
        $this->_price = $price;
    }

    /**
     * @return mixed
     */
    public function getName() {

        return $this->_name;
    }

    /**
     * @return mixed
     */
    public function getDescription() {

        return $this->_description;
    }

    /**
     * @return mixed
     */
    public function getPrice() {

        return $this->_price;
    }

    /**
     * @return mixed
     */
    public function getVegetarian() {

        return $this->_vegetarian;
    }

}

_pancake_house_menu = $pancake_house_menu;
        $this->_diner_menu = $diner_menu;

    }

    public function printMenu() {
        echo 'Breakfast Menu:', PHP_EOL;
        echo '=================', PHP_EOL;

        $pancake_iterator = $this->_pancake_house_menu->createIterator();

        $this->printMenuByIterator($pancake_iterator);

        echo PHP_EOL;
        echo 'Lunch Menu:', PHP_EOL;
        echo '=================', PHP_EOL;

        $diner_iterator = $this->_diner_menu->createIterator();

        $this->printMenuByIterator($diner_iterator);
    }

    protected function printMenuByIterator(MenuIterator $iterator) {
        while($iterator->hasNext()) {
            $menu_item = $iterator->next();
            echo 'name: ', $menu_item->getName(), PHP_EOL;
            echo 'price: ', $menu_item->getPrice(), PHP_EOL;
            echo 'description: ', $menu_item->getDescription(), PHP_EOL;
            echo 'vegetarian: ', $menu_item->getVegetarian(), PHP_EOL;
        }
    }

}
发表在 DesignPattern | 留下评论

Nginx Too many open files 问题

之前晚上直播出现 Too many open files, 很多接口 access_log 出现500报错

查了下资料,更改步骤如下:

/etc/sysctl.conf
	fs.file-max = 70000 (这个数值应当大于等于下面的硬限制)

/etc/security/limits.conf
	nginx       soft    nofile  10000
	nginx       hard    nofile  30000

让上面的配置生效
	sysctl -p

设置nginx应用层面的限制
vim /etc/nginx/nginx.conf
	
	# set open fd limit to 30000
	worker_rlimit_nofile 30000;

测试:

ab -r -k -n200 -c30 -H "User-Agent: Test By George" "http://api.ltwen.com/test/ab"

参考资料

https://www.cyberciti.biz/faq/linux-unix-nginx-too-many-open-files/

发表在 nginx | 留下评论