Skip to content

Commit 4287d14

Browse files
committed
read me
1 parent 8f8f238 commit 4287d14

File tree

1 file changed

+58
-16
lines changed

1 file changed

+58
-16
lines changed

README.md

Lines changed: 58 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,25 @@ This package provides the artisan command `ratchet:serve` that will start a [Rat
1414
# Installation
1515
Install with composer
1616
~~~
17-
composer require askedio/laravel-ratchet:dev-master
17+
composer require askedio/laravel-ratchet
1818
~~~
1919

20-
Register in the providers array in `config/app.php`
20+
Register the `provider` in `config/app.php`.
2121
~~~
2222
Askedio\LaravelRatchet\Providers\LaravelRatchetServiceProvider::class,
2323
~~~
2424

2525
# Example
26-
[RatchetServerExample.php](https://github.com/Askedio/laravel-ratchet/blob/master/src/RatchetServerExample.php) is the default class used for the Ratchet Server, a basic echo server. Here is another example:
26+
[RatchetServerExample.php](https://github.com/Askedio/laravel-ratchet/blob/master/src/RatchetServerExample.php), a basic echo server, is used when you do not define a class. Here is another example:
2727
~~~
2828
<?php
2929
3030
namespace App;
3131
3232
use Ratchet\ConnectionInterface;
33+
use Askedio\LaravelRatchet\RatchetServer;
3334
34-
class RatchetServer extends \Askedio\LaravelRatchet\RatchetServer
35+
class RatchetServer extends RatchetServer
3536
{
3637
public function onMessage(ConnectionInterface $conn, $input)
3738
{
@@ -51,10 +52,15 @@ class RatchetServer extends \Askedio\LaravelRatchet\RatchetServer
5152
~~~
5253
You'll need to change the class to `App\RatchetServer::class` in your command line or config.
5354
~~~
54-
php artisan ratchet:serve --class=App\RatchetServer::class
55+
php artisan ratchet:serve --class="\App\RatchetServer::class"
5556
~~~
5657

5758
# Command Line
59+
To use the default values from the configuration simple run the command as follows:
60+
~~~
61+
php artisan ratchet:serve
62+
~~~
63+
You can also define configuration items on the command line:
5864
~~~
5965
php artisan ratchet:serve --help
6066
@@ -70,20 +76,20 @@ Options:
7076

7177

7278
# Configuration
73-
You can configure the default host, port, class and max connections in `config/ratchet.php`, publish the config to make adjustments.
79+
There are several configuration values that you will want to change. Publish the configuration then you can edit `config/ratchet.php`.
7480
~~~
75-
php artisan vendor:publish --class=Askedio\LaravelRatchet\Providers\LaravelRatchetServiceProvider::class
81+
php artisan vendor:publish --class="\Askedio\LaravelRatchet\Providers\LaravelRatchetServiceProvider::class"
7682
~~~
7783
### Configuration Options
78-
* class: Your MessageComponentInterface or WampServerInterface class (or the packages wrappers).
79-
* host: The host to listen on.
80-
* port: The port to listen on.
81-
* connectionLimit: The total number of connections allowed (RatchetServer only).
82-
* throttle: Throttle connections and messages with [Throttle](https://github.com/GrahamCampbell/Laravel-Throttle)
83-
* onOpen: limit:delay for connections.
84-
* onMessage: limit:delay for messages.
85-
* abortOnMessageThrottle:
86-
* blackList: Collection or Model of the hosts to ban using [IpBlackList](http://socketo.me/docs/black).
84+
* **class**: Your MessageComponentInterface or WampServerInterface class.
85+
* **host**: The host to listen on.
86+
* **port**: The port to listen on.
87+
* **connectionLimit**: The total number of connections allowed (RatchetServer only).
88+
* **throttle**: [Throttle](https://github.com/GrahamCampbell/Laravel-Throttle) connections and messages.
89+
* **onOpen**: limit:delay for connections.
90+
* **onMessage**: limit:delay for messages.
91+
* **abortOnMessageThrottle**: disconnect client when message throttle triggered.
92+
* **blackList**: Collection or Model of the hosts to ban using [IpBlackList](http://socketo.me/docs/black).
8793

8894
# Options
8995
Send a message to the current connection.
@@ -99,6 +105,42 @@ Close current connection.
99105
$this->abort($conn);
100106
~~~
101107

108+
# Supervisor Configuration
109+
> Supervisor is a client/server system that allows its users to control a number of processes on UNIX-like operating systems.
110+
111+
Things crash and long running processes need to be monitored. We can use [Supervisor](http://supervisord.org/index.html) to help with this.
112+
113+
114+
### Install supervisor.
115+
~~~
116+
sudo apt-get install supervisor
117+
~~~
118+
### Create the config.
119+
120+
Replace `/home/forge/app.com/` with the path to your application.
121+
~~~
122+
sudo cat <<EOF > /etc/supervisor/conf.d/laravel-ratchet.conf
123+
[program:laravel-ratchet]
124+
process_name=%(program_name)s_%(process_num)02d
125+
command=php /home/forge/app.com/artisan ratchet:serve
126+
autostart=true
127+
autorestart=true
128+
user=vagrant
129+
numprocs=1
130+
redirect_stderr=true
131+
stdout_logfile=/home/forge/app.com/ratchet.log
132+
EOF
133+
~~~
134+
### Enable & Start.
135+
~~~
136+
sudo supervisorctl reread
137+
138+
sudo supervisorctl update
139+
140+
supervisorctl start laravel-ratchet:*
141+
~~~
142+
143+
102144
# Testing
103145
See contributing.
104146

0 commit comments

Comments
 (0)