Exemplo n.º 1
0
 public function __construct()
 {
     parent::__construct();
     //
     // Make sure that bool valued settings are cast to ints.
     //
     $this->_settings = array(self::ALLOW_USER_REGISTRATION => 1, self::EXECUTABLE_TAR => Framework_HostOs::isWindows() ? '' : 'tar', self::EXECUTABLE_GIT => 'git' . (Framework_HostOs::isWindows() ? '.exe' : ''), self::EXECUTABLE_PHP => 'php' . (Framework_HostOs::isWindows() ? '.exe' : '') . (php_ini_loaded_file() ? ' -c ' . htmlentities(str_replace(array('\\', '//'), '/', php_ini_loaded_file())) : ''), self::EXECUTABLE_SVN => 'svn' . (Framework_HostOs::isWindows() ? '.exe' : ''), self::INTERNAL_BUILDER_ACTIVE => CINTIENT_INTERNAL_BUILDER_ACTIVE, self::VERSION => '');
 }
Exemplo n.º 2
0
 public function update(&$rev)
 {
     // We can't use "git --git-dir={$this->getLocal()} pull", it's wrong
     $drive = '';
     if (Framework_HostOs::isWindows()) {
         $drive = substr($this->getLocal(), 0, strpos($this->getLocal(), ':') + 1) . ' && ';
     }
     $command = (empty($this->_envVars) ? '' : $this->getEnvVars() . ' && ') . "{$drive} cd {$this->getLocal()} && {$GLOBALS['settings'][SystemSettings::EXECUTABLE_GIT]} pull";
     $proc = new Framework_Process();
     $proc->setExecutable($command, false);
     // false for no escapeshellcmd() (because of the ';')
     $proc->run();
     if (($return = $proc->getReturnValue()) != 0) {
         SystemEvent::raise(SystemEvent::ERROR, "Could not update local working copy. [COMMAND=\"{$command}\"] [RET={$return}] [STDERR=\"{$proc->getStderr()}\"] [STDOUT=\"{$proc->getStdout()}\"]", __METHOD__);
         return false;
     }
     $rev = $this->_getLocalRevision();
     SystemEvent::raise(SystemEvent::DEBUG, "Updated local. [REV={$rev}] [COMMAND=\"{$command}\"] [RET={$return}] [STDERR=\"{$proc->getStderr()}\"] [STDOUT=\"{$proc->getStdout()}\"]", __METHOD__);
     return true;
 }
Exemplo n.º 3
0
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Cintient. If not, see <http://www.gnu.org/licenses/>.
 *
 */
// TODO: centralize the initalization stuff that is common to web, ajax
// and builder handlers. (this builder could be called by a crontab)
require_once dirname(__FILE__) . '/../config/cintient.conf.php';
SystemEvent::setSeverityLevel(CINTIENT_LOG_SEVERITY);
$GLOBALS['settings'] = SystemSettings::load();
// Pull up system settings
// Temporarily disable the background build handler in Windows, while
// binaries aren't being dealt with in the installer.
if (Framework_HostOs::isWindows()) {
    SystemEvent::raise(SystemEvent::INFO, "Background builds are temporarily disabled in Windows.", 'buildHandler');
    return false;
}
$buildProcess = new Framework_Process($GLOBALS['settings'][SystemSettings::EXECUTABLE_PHP]);
$buildProcess->addArg(CINTIENT_INSTALL_DIR . 'src/workers/runBuildWorker.php');
if (!$buildProcess->isRunning()) {
    if (!$buildProcess->run(true)) {
        SystemEvent::raise(SystemEvent::ERROR, "Problems starting up build worker.", 'buildHandler');
    } else {
        SystemEvent::raise(SystemEvent::INFO, "Build worker left running in the background.", 'buildHandler');
    }
} else {
    SystemEvent::raise(SystemEvent::DEBUG, "Build process already running.", 'buildHandler');
}
#endif
Exemplo n.º 4
0
 /**
  * Run an external command asynchronously, i.e., don't wait for it to
  * finish.
  */
 public function runInBackground($output = self::STDOUT)
 {
     if (Framework_HostOs::isWindows()) {
         @pclose(@popen("start /B " . $this->getCmd(), "r"));
     } else {
         $outputSupression = '';
         switch ($output) {
             // Full stderr and stdout output
             // TODO: This will probably cause PHP to hang in case of running
             // in the background. In the exec() manual section, they state
             // that in these cases all ouput must be redirected to a filename
             // or other stream, or else PHP will be left hanging... Check this
             // later.
             case self::STDERR:
                 $outputSupression = ' 2>&1';
                 break;
                 // Fully silent
             // Fully silent
             case self::SILENT:
                 $outputSupression = ' > /dev/null 2>&1';
                 break;
                 // Just output stdout
             // Just output stdout
             case self::STDOUT:
             default:
                 $outputSupression = ' 2>/dev/null';
                 break;
         }
         $fullOuput = array();
         $ret = 1;
         $lastline = null;
         $command = $this->getCmd() . $outputSupression . ' &';
         SystemEvent::raise(SystemEvent::INFO, "Executing '{$command}'", __METHOD__);
         $lastline = @exec($command, $fullOutput, $ret);
         return array($lastline, $fullOutput, $ret);
     }
     return true;
 }