Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ vendor
web/vendor
web/reports/ab-archive
rSrc
/logs
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
build:
docker build -f docker/Dockerfile-chat -t socketome .

run:
docker run --rm -it -p 8080:8080 socketome

setup:
rm -rf web/vendor
mkdir -p web/vendor
cp -r vendor/cujojs/when web/vendor/when
Expand Down
18 changes: 16 additions & 2 deletions bin/run-all-the-things.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php
// Dear FIG: Thank you for PSR-0!
use Ratchet\App;
use Ratchet\Wamp\ServerProtocol;

use Ratchet\Website\Chat\Bot;
use Ratchet\Website\Chat\ChatRoom;
use Ratchet\Website\MessageLogger;

use React\EventLoop\Loop;

use Monolog\Logger;
use Monolog\Handler\StreamHandler;

Expand All @@ -25,7 +26,7 @@
$login->pushHandler($stdout);
$logout->pushHandler($stdout);

$app = new App($host);
$app = new App($host, 8080, '0.0.0.0');
$app->route('/chat',
new MessageLogger( // Log events in case of "oh noes"
new ServerProtocol( // WAMP; the new hotness sub-protocol
Expand All @@ -38,5 +39,18 @@
)
);

Loop::addSignal(SIGINT, $func = function ($signal) use (&$func) {
echo 'Received signal: ', (string)$signal, PHP_EOL;

Loop::removeSignal(SIGINT, $func);
Loop::get()->stop();
});
Loop::addSignal(SIGTERM, $func = function ($signal) use (&$func) {
echo 'Received signal: ', (string)$signal, PHP_EOL;

Loop::removeSignal(SIGTERM, $func);
Loop::get()->stop();
});

Comment on lines +42 to +54
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either

Suggested change
Loop::addSignal(SIGINT, $func = function ($signal) use (&$func) {
echo 'Received signal: ', (string)$signal, PHP_EOL;
Loop::removeSignal(SIGINT, $func);
Loop::get()->stop();
});
Loop::addSignal(SIGTERM, $func = function ($signal) use (&$func) {
echo 'Received signal: ', (string)$signal, PHP_EOL;
Loop::removeSignal(SIGTERM, $func);
Loop::get()->stop();
});
Loop::addSignal(SIGINT, $func = function ($signal) use (&$func) {
echo 'Received signal: ', (string)$signal, PHP_EOL;
Loop::get()->stop();
});
Loop::addSignal(SIGTERM, $func = function ($signal) use (&$func) {
echo 'Received signal: ', (string)$signal, PHP_EOL;
Loop::get()->stop();
});

or

Suggested change
Loop::addSignal(SIGINT, $func = function ($signal) use (&$func) {
echo 'Received signal: ', (string)$signal, PHP_EOL;
Loop::removeSignal(SIGINT, $func);
Loop::get()->stop();
});
Loop::addSignal(SIGTERM, $func = function ($signal) use (&$func) {
echo 'Received signal: ', (string)$signal, PHP_EOL;
Loop::removeSignal(SIGTERM, $func);
Loop::get()->stop();
});
$func = function ($signal) use ($func) {
echo 'Received signal: ', (string)$signal, PHP_EOL;
Loop::removeSignal(SIGINT, $func);
Loop::removeSignal(SIGTERM, $func);
Loop::get()->stop();
};
Loop::addSignal(SIGINT, $func);
Loop::addSignal(SIGTERM, $func);

But probably also a stop function, if it doesn't exists on Ratchet, would help.

// GO GO GO!
$app->run();
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "cboden/Ratchet-website"
"name": "cboden/socketome"
, "homepage": "http://socketo.me"
, "license": "DBAD"
, "authors": [
Expand All @@ -10,7 +10,9 @@
]
, "require": {
"php": ">=5.4.0"
, "cboden/Ratchet": "0.3.*"
, "cboden/ratchet": "^0.4"
, "react/event-loop": "^1.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
, "react/event-loop": "^1.0"
, "react/event-loop": "^1.3"

, "react/socket": "^1.0"
, "silex/silex": "1.0.*@dev"
, "twig/twig": "1.10.*"
, "monolog/monolog": "~1.6"
Expand Down
Loading