Esempio n. 1
0
 public function __destruct()
 {
     $this->log->log('Closed jobQueue');
     unlink($this->pipefile);
     fclose($this->jobQueueLog);
     parent::__destruct();
 }
Esempio n. 2
0
 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/';
 }
Esempio n. 3
0
 public function __construct($gremlin, $config, $subtask = Tasks::IS_NOT_SUBTASK)
 {
     $this->enabledLog = false;
     parent::__construct($gremlin, $config, $subtask);
 }
Esempio n. 4
0
 public function __construct($gremlin, $config, $subtask = Tasks::IS_NOT_SUBTASK)
 {
     parent::__construct($gremlin, $config, $subtask);
     $this->php = new Phpexec();
     if (!$this->php->isValid()) {
         throw new InvalidPHPBinary($this->php->getVersion());
     }
     self::$PROP_OPTIONS = array('alternative' => self::$PROP_ALTERNATIVE, 'reference' => self::$PROP_REFERENCE, 'heredoc' => self::$PROP_HEREDOC, 'delimiter' => self::$PROP_DELIMITER, 'noDelimiter' => self::$PROP_NODELIMITER, 'variadic' => self::$PROP_VARIADIC, 'count' => self::$PROP_COUNT, 'fullnspath' => self::$PROP_FNSNAME, 'absolute' => self::$PROP_ABSOLUTE, 'alias' => self::$PROP_ALIAS, 'origin' => self::$PROP_ORIGIN, 'encoding' => self::$PROP_ENCODING, 'intval' => self::$PROP_INTVAL, 'strval' => self::$PROP_STRVAL, 'enclosing' => self::$PROP_ENCLOSING, 'args_max' => self::$PROP_ARGS_MAX, 'args_min' => self::$PROP_ARGS_MIN, 'bracket' => self::$PROP_BRACKET, 'close_tag' => self::$PROP_CLOSETAG);
     $this->php->getTokens();
     Precedence::preloadConstants($this->php->getActualVersion());
     $this->precedence = new Precedence();
 }
Esempio n. 5
0
 private function restartNeo4j()
 {
     display('Cleaning with restart');
     $this->config = $this->config;
     // preserve data/dbms/auth to preserve authentication
     if (file_exists($this->config->neo4j_folder . '/data/dbms/auth')) {
         $sshLoad = 'mv data/dbms/auth ../auth; rm -rf data; mkdir -p data/dbms; mv ../auth data/dbms/auth; mkdir -p data/log; mkdir -p data/scripts ';
     } else {
         $sshLoad = 'rm -rf data; mkdir -p data; mkdir -p data/log; mkdir -p data/scripts ';
     }
     // if neo4j-service.pid exists, we kill the process once
     if (file_exists($this->config->neo4j_folder . '/data/neo4j-service.pid')) {
         shell_exec('kill -9 $(cat ' . $this->config->neo4j_folder . '/data/neo4j-service.pid) 2>>/dev/null; ');
     }
     shell_exec('cd ' . $this->config->neo4j_folder . '; ' . $sshLoad);
     if (!file_exists($this->config->neo4j_folder . '/conf/')) {
         print "No conf folder in {$this->config->neo4j_folder}\n";
     } elseif (!file_exists($this->config->neo4j_folder . '/conf/neo4j-server.properties')) {
         print "No neo4j-server.properties file in {$this->config->neo4j_folder}/conf/\n";
     } else {
         $neo4j_config = file_get_contents($this->config->neo4j_folder . '/conf/neo4j-server.properties');
         if (preg_match('/org.neo4j.server.webserver.port *= *(\\d+)/m', $neo4j_config, $r)) {
             if ($r[1] != $this->config->neo4j_port) {
                 print "Warning : Exakat's port and Neo4j's port are not the same ({$r['1']} / {$this->config->neo4j_port})\n";
             }
         }
     }
     // checking that the server has indeed restarted
     if (Tasks::$semaphore !== null) {
         fclose(Tasks::$semaphore);
         $this->doRestart();
         Tasks::$semaphore = @stream_socket_server("udp://0.0.0.0:" . Tasks::$semaphorePort, $errno, $errstr, STREAM_SERVER_BIND);
     } else {
         $this->doRestart();
     }
     display('Database cleaned with restart');
     try {
         $res = $this->gremlin->serverInfo();
         display('Restarted Neo4j cleanly');
     } catch (Exception $e) {
         display('Didn\'t restart neo4j cleanly');
     }
     $this->gremlin->query("g.addV('delete', true)");
 }