Skip to content

Commit fe5855e

Browse files
committed
added check for EPROCESS_AUTOLOAD, fixed formatting
1 parent 08b55e6 commit fe5855e

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

EProcess/Adapter/BaseAdapter.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,22 @@ public function __construct(LoopInterface $loop)
1717

1818
protected function createUnixSocket()
1919
{
20-
if(!defined('SOCKET_PATH'))
21-
throw new \Exception("SOCKET_PATH is not defined.");
22-
23-
if(!is_writable(SOCKET_PATH)){
24-
if(!mkdir(SOCKET_PATH))
25-
throw new \Exception("Cannot create folder at SOCKET_PATH.");
20+
if (!defined('EPROCESS_SOCKET_DIR')) {
21+
throw new \Exception("EPROCESS_SOCKET_DIR is not defined.");
2622
}
2723

28-
$unixFile = sprintf('%s/%s.sock', SOCKET_PATH, $this->node);
24+
if (!defined('EPROCESS_AUTOLOAD')) {
25+
throw new \Exception('EPROCESS_AUTOLOAD is not defined.');
26+
}
27+
28+
if (!is_writable(EPROCESS_SOCKET_DIR)) {
29+
throw new \Exception(sprintf("Cannot write to %s.", EPROCESS_SOCKET_DIR));
30+
}
31+
32+
$unixFile = sprintf('%s/%s.sock', EPROCESS_SOCKET_DIR, $this->node);
2933
$unix = sprintf('unix://%s', $unixFile);
3034

31-
$cleanup = function() use ($unixFile) {
35+
$cleanup = function () use ($unixFile) {
3236
$this->loop->stop();
3337
@unlink($unixFile);
3438
};
@@ -40,5 +44,6 @@ protected function createUnixSocket()
4044
}
4145

4246
abstract public function create($class, array $data = []);
47+
4348
abstract public function kill();
4449
}

examples/autoload.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
declare(ticks = 1);
44

55
define('EPROCESS_AUTOLOAD', __FILE__);
6+
define('EPROCESS_SOCKET_DIR', '/tmp/eprocess');
67

78
$loader = require __DIR__ . '/../vendor/autoload.php';
89

examples/simple.php

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

3-
define('SOCKET_PATH', '/tmp/eprocess');
4-
53
require_once __DIR__ . '/autoload.php';
64

75
use Doctrine\Common\Annotations\AnnotationRegistry;

0 commit comments

Comments
 (0)