Merge "Disable transaction warnings for automatic trx."
[mediawiki.git] / maintenance / hiphop / run-server
blob1c4b51f48c2f243b3ac9b59c9ce50a4a5abe385f
1 #!/usr/bin/hphpi -f
2 <?php
4 require( __DIR__ . '/../Maintenance.php' );
6 class RunHipHopServer extends Maintenance {
7         function __construct() {
8                 parent::__construct();
9                 $this->addOption( 'interpret', 'Run in interpreted mode' );
10         }
12         function execute() {
13                 if ( $this->hasOption( 'interpret' ) ) {
14                         $this->runInterpreted();
15                 } else {
16                         $this->runCompiled();
17                 }
18         }
20         function runCompiled() {
21                 global $wgHipHopBuildDirectory;
22                 $thisDir = realpath( __DIR__ );
23                 $IP = realpath( "$thisDir/../.." );
24                 if ( strval( $wgHipHopBuildDirectory ) !== '' ) {
25                         $buildDir = $wgHipHopBuildDirectory;
26                 } else {
27                         $buildDir = "$thisDir/build";
28                 }
30                 if ( file_exists( "$buildDir/source" ) ) {
31                         $sourceBase = "$buildDir/source";
32                 } else {
33                         $sourceBase = realpath( "$IP/.." );
34                 }
36                 passthru( 
37                         'cd ' . wfEscapeShellArg( $sourceBase ) . " && " .
38                         'MW_INSTALL_PATH=' . wfEscapeShellArg( $IP ) . ' ' .
39                         wfEscapeShellArg( 
40                                 "$buildDir/persistent/mediawiki-hphp",
41                                 '-c', "$thisDir/server.conf",
42                                 '-v', "Server.SourceRoot=$sourceBase",
43                                 '-v', "Server.IncludeSearchPaths.0=$sourceBase",
44                                 '-v', 'ServerVariables.MW_COMPILED=1',
45                                 '--mode=server',
46                                 '--port=8080'
47                         ),
48                         $ret
49                 );
50                 exit( $ret );
51         }
53         function runInterpreted() {
54                 $thisDir = realpath( __DIR__ );
55                 $IP = realpath( "$thisDir/../.." );
56                 $sourceBase = realpath( "$IP/.." );
58                 passthru(
59                         'cd ' . wfEscapeShellArg( $sourceBase ) . " && " .
60                         'MW_INSTALL_PATH=' . wfEscapeShellArg( $IP ) . ' ' .
61                         wfEscapeShellArg(
62                                 'hphpi',
63                                 '-c', "$thisDir/server.conf",
64                                 '-v', "Server.SourceRoot=$sourceBase",
65                                 '-v', "Server.IncludeSearchPaths.0=$sourceBase",
66                                 '--mode=server',
67                                 '--port=8080'
68                         ),
69                         $ret
70                 );
71                 exit( $ret );
72         }
74 $maintClass = 'RunHipHopServer';
75 require_once( RUN_MAINTENANCE_IF_MAIN );