Skip to content

Commit 63be3f2

Browse files
committed
+ anycable:server: recognize Reverb configuration
1 parent bb868b4 commit 63be3f2

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## master
44

5+
## 0.1.2
6+
7+
- Use Reverb env vars as defaults in `anycable:server`.
8+
59
## 0.1.1
610

711
- Fix using `http_broadcas_url` configuration parameter.

src/Commands/AnyCableServerCommand.php

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,35 @@ protected function runBinary($binaryPath)
208208
$args = array_merge($args, $extraArgs);
209209
}
210210

211-
$process = new Process($args);
211+
// Set up environment variables
212+
$env = $_ENV;
213+
214+
// Set ANYCABLE_BROADCAST_ADAPTER=http if not set
215+
if (!isset($env['ANYCABLE_BROADCAST_ADAPTER'])) {
216+
$env['ANYCABLE_BROADCAST_ADAPTER'] = 'http';
217+
}
218+
219+
// Set ANYCABLE_PUSHER_APP_ID to REVERB_APP_ID if not set and the latter exists
220+
if (!isset($env['ANYCABLE_PUSHER_APP_ID']) && isset($env['REVERB_APP_ID'])) {
221+
$env['ANYCABLE_PUSHER_APP_ID'] = $env['REVERB_APP_ID'];
222+
}
223+
224+
// Set ANYCABLE_PUSHER_APP_KEY to REVERB_APP_KEY if not set and the latter exists
225+
if (!isset($env['ANYCABLE_PUSHER_APP_KEY']) && isset($env['REVERB_APP_KEY'])) {
226+
$env['ANYCABLE_PUSHER_APP_KEY'] = $env['REVERB_APP_KEY'];
227+
}
228+
229+
// Set ANYCABLE_PUSHER_SECRET to REVERB_APP_SECRET if not set and the latter exists
230+
if (!isset($env['ANYCABLE_PUSHER_SECRET']) && isset($env['REVERB_APP_SECRET'])) {
231+
$env['ANYCABLE_PUSHER_SECRET'] = $env['REVERB_APP_SECRET'];
232+
}
233+
234+
// Set ANYCABLE_PRESETS to broker if not set
235+
if (!isset($env['ANYCABLE_PRESETS'])) {
236+
$env['ANYCABLE_PRESETS'] = 'broker';
237+
}
238+
239+
$process = new Process($args, null, $env);
212240
$process->setTimeout(null);
213241
$process->setTty(Process::isTtySupported());
214242

0 commit comments

Comments
 (0)