Laravel swoole安装及使用及inotify热更新 (Linux centos环境)

###1. 下载swoole
pecl.php.net/package/swoole

###2. 安装swoole扩展

     tar zxvf swoole-4.4.12.tgz  
     cd swoole-4.4.12
     phpize 
     ./configure --with-php-config=/usr/local  /php/bin/php-config
      make && make install   
     echo  "extension=swoole.so"  >> /usr/local/php/etc/php.ini
     /etc/init.d/php-fpm restart 

3. 查看是否安装成功

 php -m | grep swoole 

4. Laravel6 安装 swoole

composer require swooletw/laravel-swoole
添加服务提供者到config/app.php
   'providers' => [
        SwooleTW\Http\LaravelServiceProvider::class,
    ],

5. 发布(不发布的话storage下的log会没日志 )

  php artisan vendor:publish --tag=laravel-swoole

6. 安装成功,运行成功

图片.png

7. 查看版本或帮助

      php artisan help swoole:http   # 查看帮助
      php artisan swoole:http start  # 启动服务
      php artisan swoole:http  restart   # 重启服务 
      php artisan swoole:http reload   # 热更新swoole服务
      php artisan swoole:http infos  # 查看版本 

图片.png

swoole 使用确实爽速度快了好多倍, 之前需要一百多毫秒的一个接口现在一个接口8,9 毫秒就搞定了。

相关网页: github.com/swooletw/laravel-swoole

swoole + inotify 热更新

相关web

1. 安装包

     http://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz

2. 使用方法及测试方法

    https://blog.csdn.net/zz_aiytag/article/details/107826135

3. centos7.2 rsync + inotify 安装使用实时备份

    https://blog.csdn.net/weixin_39963973/article/details/78551926

4 . 报错处理

    error while loading shared libraries: libinotifytools.so.0: cannot open shared object file
    https://blog.csdn.net/wangxin6722513/article/details/44218893 

安装shell

#!/bin/bash
cd /tmp 
wget http://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz
tar zxvf inotify-tools-3.14
cd /tmp/inotify-tools-3.14
./configure –prefix=/usr/local/inotify 
make && make install 
echo "/usr/lib64/mysol" >> /etc/ld.so.conf 
ldconfig
export LD_LIBRARY_PATH=/usr/local/inotify/lib:$LD_LIBRARY_PATH 

测试脚本 /tmp/demo.sh , 当/tmpsrcdir 有变化 时就会执行

#!/bin/bash
 srcdir=/tmp/srcdir
 inotifywait -rq --timefmt '%d/%m/%y-%H:%M' --format '%T %w%f' -e modify,create,attrib ${srcdir} \
  | while read file
 do
   echo "${file} is notified!"
 done
本作品采用《CC 协议》,转载必须注明作者和本文链接
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!