mp-php / fuel-packages-ratchet
此包最新版本(0.1)没有可用的许可证信息。
0.1
2013-04-12 15:22 UTC
Requires
- cboden/ratchet: 0.2.*
- react/zmq: 0.1.*
This package is auto-updated.
Last update: 2024-09-19 19:37:57 UTC
README
安装 ZeroMQ
安装
设置到 fuel/packages/ratchet
- 使用 composer https://packagist.org.cn/packages/mp-php/fuel-packages-ratchet
- git submodule add
- 下载 zip
如果您使用 git submodule 或下载 zip,则必须安装 vendors
$ cd fuel/packages/ratchet
$ php composer.phar install
配置
在 app/config/config.php 中
'always_load' => array('packages' => array(
'ratchet',
...
将 packages/ratchet/config/ratchet.php 复制到 app/config 目录下并编辑
<?php
return array(
'classes' => array(
'default' => array(
'domain' => 'example.com',
'port' => '8001',
'zmq_port' => '5555',
),
'Ratchet_Ws' => array(
'domain' => 'example.com',
'port' => '8001',
),
'Ratchet_Wamp' => array(
'domain' => 'example.com',
'port' => '8002',
'zmq_port' => '5555',
),
),
);
用法
$ php oil r ratchet:help
使用 Supervisor 运行
# Install with easy_install command
$ sudo easy_install supervisor
# Generate configure file
$ echo_supervisord_conf > fuel/packages/ratchet/supervisor.conf
supervisor.conf 示例
添加以下内容
My_Ratchet_Ws 是 fuel/app/classes/my/ratchet/ws.php,它扩展了 Ratchet_Ws
[program:ratchet]
environment = FUEL_ENV=production
command = php oil r ratchet:ws My_Ratchet_Ws
numprocs = 1
autostart = true
autorestart = true
user = root
stdout_logfile = fuel/app/logs/supervisor/info.log
stdout_logfile_maxbytes = 1MB
stderr_logfile = fuel/app/logs/supervisor/error.log
stderr_logfile_maxbytes = 1MB
示例命令
# In FuelPHP project root
# Up
$ sudo supervisord -c fuel/packages/ratchet/supervisor.conf
# Check Status
$ sudo supervisorctl -c fuel/packages/ratchet/supervisor.conf status
# Stop
$ sudo supervisorctl -c fuel/packages/ratchet/supervisor.conf stop all
# Start
$ sudo supervisorctl -c fuel/packages/ratchet/supervisor.conf start all
# Restart
$ sudo supervisorctl -c fuel/packages/ratchet/supervisor.conf restart all
带有 Makefile 的示例命令
# make up
up:
@echo 'Please manually run the following command:'
@echo 'sudo supervisord -c fuel/packages/ratchet/supervisor.conf'
# make down
down:
sudo supervisorctl -c fuel/packages/ratchet/supervisor.conf stop all && sudo rm /tmp/supervisor.sock
# make start-all
start-all:
sudo supervisorctl -c fuel/packages/ratchet/supervisor.conf start all
# make stop-all
stop-all:
sudo supervisorctl -c fuel/packages/ratchet/supervisor.conf stop all
# make restart-all
restart-all:
sudo supervisorctl -c fuel/packages/ratchet/supervisor.conf restart all
# make status
status:
sudo supervisorctl -c fuel/packages/ratchet/supervisor.conf status
# make help
help:
@echo 'Commands:'
@echo ' make up'
@echo ' make down'
@echo ' make start-all'
@echo ' make stop-all'
@echo ' make restart-all'
@echo ' make status'
许可证
版权所有 2013,Mamoru Otsuka。在 MIT 许可证下授权: https://open-source.org.cn/licenses/mit-license.php