public function __construct($gremlin, $config, $subTask = self::IS_NOT_SUBTASK)
{
$this->gremlin = $gremlin;
$this->config = $config;
$this->is_subtask = $subTask;
assert(defined('static::CONCURENCE'), get_class($this) . " is missing CONCURENCE\n");
if (static::CONCURENCE !== self::ANYTIME && $subTask === self::IS_NOT_SUBTASK) {
if (self::$semaphore === null) {
if (static::CONCURENCE === self::QUEUE) {
Tasks::$semaphorePort = 7610;
} elseif (static::CONCURENCE === self::SERVER) {
Tasks::$semaphorePort = 7611;
} elseif (static::CONCURENCE === self::DUMP) {
Tasks::$semaphorePort = 7612;
} else {
Tasks::$semaphorePort = 7613;
}
if ($socket = @stream_socket_server("udp://0.0.0.0:" . Tasks::$semaphorePort, $errno, $errstr, STREAM_SERVER_BIND)) {
Tasks::$semaphore = $socket;
} else {
throw new AnotherProcessIsRunning();
}
}
}
if ($this->enabledLog) {
$a = get_class($this);
$task = strtolower(substr($a, strrpos($a, '\\') + 1));
$this->log = new Log($task, $this->config->projects_root . '/projects/' . $this->config->project);
}
if ($this->config->project != 'default' && file_exists($this->config->projects_root . '/projects/' . $this->config->project)) {
$this->datastore = new Datastore($this->config);
}
if (!file_exists($this->config->projects_root . '/projects/')) {
mkdir($this->config->projects_root . '/projects/', 0700);
}
if (!file_exists($this->config->projects_root . '/projects/.exakat/')) {
mkdir($this->config->projects_root . '/projects/.exakat/', 0700);
}
$this->exakatDir = $this->config->projects_root . '/projects/.exakat/';
}