Merge "Follow-up I0b781c11 (2a55449): use User::getAutomaticGroups()."
[lhc/web/wiklou.git] / maintenance / hiphop / run-server
1 #!/usr/bin/hphpi -f
2 <?php
3
4 require( __DIR__ . '/../Maintenance.php' );
5
6 class RunHipHopServer extends Maintenance {
7 function __construct() {
8 parent::__construct();
9 $this->addOption( 'interpret', 'Run in interpreted mode' );
10 }
11
12 function execute() {
13 if ( $this->hasOption( 'interpret' ) ) {
14 $this->runInterpreted();
15 } else {
16 $this->runCompiled();
17 }
18 }
19
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 }
29
30 if ( file_exists( "$buildDir/source" ) ) {
31 $sourceBase = "$buildDir/source";
32 } else {
33 $sourceBase = realpath( "$IP/.." );
34 }
35
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 }
52
53 function runInterpreted() {
54 $thisDir = realpath( __DIR__ );
55 $IP = realpath( "$thisDir/../.." );
56 $sourceBase = realpath( "$IP/.." );
57
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 }
73 }
74 $maintClass = 'RunHipHopServer';
75 require_once( RUN_MAINTENANCE_IF_MAIN );