Skip to content

Commit 49ea9cb

Browse files
author
vagrant
committed
added custom definition for sockets folder
1 parent e9eaba9 commit 49ea9cb

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

EProcess/Adapter/BaseAdapter.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace EProcess\Adapter;
44

5+
use Ratchet\Wamp\Exception;
56
use React\EventLoop\LoopInterface;
67

78
abstract class BaseAdapter
@@ -17,7 +18,15 @@ public function __construct(LoopInterface $loop)
1718

1819
protected function createUnixSocket()
1920
{
20-
$unixFile = sprintf('tmp/%s.sock', $this->node);
21+
if(!defined('SOCKET_PATH'))
22+
throw new \Exception("SOCKET_PATH is not defined.");
23+
24+
if(!is_writable(SOCKET_PATH)){
25+
if(!mkdir(SOCKET_PATH))
26+
throw new \Exception("Cannot create folder at SOCKET_PATH.");
27+
}
28+
29+
$unixFile = sprintf('%s/%s.sock', SOCKET_PATH, $this->node);
2130
$unix = sprintf('unix://%s', $unixFile);
2231

2332
$cleanup = function() use ($unixFile) {

examples/simple.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
define('SOCKET_PATH', '/tmp/eprocess');
4+
35
require_once __DIR__ . '/autoload.php';
46

57
use Doctrine\Common\Annotations\AnnotationRegistry;

0 commit comments

Comments
 (0)