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 协议》,转载必须注明作者和本文链接
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

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