Skip to content
GitLab
Explore
Sign in
project
provision
Compare revisions
cbd9cc0b3c7d745dc795aca1c86bfde17a3ef639 to php-server
Hide whitespace changes
Inline
Side-by-side
src/Service/Http/Apache/Configuration/SiteConfiguration.php
View file @
7918e2fb
...
...
@@ -23,7 +23,7 @@ class SiteConfiguration extends Configuration {
function
filename
()
{
$file
=
$this
->
context
->
getProperty
(
'uri'
)
.
'.conf'
;
return
$this
->
context
->
applicat
ion
->
getConfig
()
->
get
(
'config_path'
)
.
'/'
.
$this
->
service
->
provider
->
name
.
'/'
.
$this
->
service
->
getType
()
.
'/vhost.d/'
.
$file
;
return
$this
->
context
->
getProvis
ion
()
->
getConfig
()
->
get
(
'config_path'
)
.
'/'
.
$this
->
service
->
provider
->
name
.
'/'
.
$this
->
service
->
getType
()
.
'/vhost.d/'
.
$file
;
}
function
process
()
{
...
...
src/Service/Http/HttpPhpService.php
0 → 100644
View file @
7918e2fb
<?php
/**
* @file
* The Provision HttpApacheService class.
*
* @see \Provision_Service_http_apache
*/
namespace
Aegir\Provision\Service\Http
;
use
Aegir\Provision\Robo\ProvisionCollectionBuilder
;
use
Aegir\Provision\Service\Http\Apache\Configuration\PlatformConfiguration
;
use
Aegir\Provision\Service\Http\Apache\Configuration\ServerConfiguration
;
use
Aegir\Provision\Service\Http\Apache\Configuration\SiteConfiguration
;
use
Aegir\Provision\Service\HttpService
;
use
Aegir\Provision\ServiceSubscription
;
use
Robo\Result
;
use
Aegir\Provision\Service\Http\Php\PhpServer
;
use
Symfony\Component\Process\Process
;
/**
* Class HttpPhpService
*
* @package Aegir\Provision\Service\Http
*/
class
HttpPhpService
extends
HttpService
{
const
SERVICE_TYPE
=
'php'
;
const
SERVICE_TYPE_NAME
=
'PHP Server'
;
public
function
verifyServer
()
{
$host
=
$this
->
getContext
()
->
getProperty
(
'remote_host'
);
$port
=
$this
->
getProperty
(
'http_port'
);
$this
->
getProvision
()
->
getLogger
()
->
info
(
'Running server at {host}:{port}'
,
[
'host'
=>
$host
,
'port'
=>
$port
,
]);
//
$this
->
getContext
()
->
getBuilder
()
->
build
(
PhpServer
::
class
,
[
'port'
=>
$port
]);
// $server = new PhpServer($port);
/** @var PhpServer $server */
$server
=
$this
->
getContext
()
->
getBuilder
()
->
task
(
PhpServer
::
class
,
[
'port'
=>
$port
]);
$server
->
host
(
$host
);
$server
->
dir
(
__DIR__
.
'/Php/servertest'
);
$server
->
background
();
$server
->
run
();
//
$pid
=
$server
->
getProcess
()
->
getPid
();
$this
->
getProvision
()
->
getLogger
()
->
info
(
'Server started at {host}:{port} running as process {pid}'
,
[
'host'
=>
$host
,
'port'
=>
$port
,
'pid'
=>
$pid
,
]);
}
public
function
verifySite
()
{
}
public
function
verifySubscription
(
ServiceSubscription
$subscription
)
{
print_r
(
$subscription
->
context
->
getProperty
(
'root'
));
$this
->
application
->
getBuilder
()
->
taskServer
(
$this
->
getProperty
(
'http_port'
))
->
dir
(
'.'
);;
}
}
src/Service/Http/Php/PhpServer.php
0 → 100644
View file @
7918e2fb
<?php
namespace
Aegir\Provision\Service\Http\Php
;
use
Robo\Common\ExecCommand
;
use
Robo\Common\ExecTrait
;
class
PhpServer
extends
\Robo\Task\Development\PhpServer
{
/**
* @var int
*/
protected
$port
;
/**
* @var string
*/
protected
$host
=
'127.0.0.1'
;
/**
* @var string
*/
protected
$command
=
'php -S %s:%d '
;
/**
* @param int $port
*/
public
function
__construct
(
$port
)
{
$this
->
port
=
$port
;
if
(
strtolower
(
PHP_OS
)
===
'linux'
)
{
$this
->
command
=
'exec php -S %s:%d '
;
}
}
/**
* @param string $host
*
* @return $this
*/
public
function
host
(
$host
)
{
$this
->
host
=
$host
;
return
$this
;
}
/**
* @param string $path
*
* @return $this
*/
public
function
dir
(
$path
)
{
$this
->
command
.
=
"-t
$path
"
;
return
$this
;
}
/**
* {@inheritdoc}
*/
public
function
getCommand
()
{
return
sprintf
(
$this
->
command
,
$this
->
host
,
$this
->
port
);
}
public
function
run
()
{
$this
->
executeCommand
(
$this
->
getCommand
());
}
public
function
getProcess
()
{
return
$this
->
process
;
}
public
function
task
()
{
}
}
\ No newline at end of file
src/Service/Http/Php/servertest/index.php
0 → 100644
View file @
7918e2fb
<h1>
<?php
print
"It Works!"
;
?>
</h1>
<p>
<?php
print
"This page is being generated by PHP web server."
?>
</p>
src/Service/HttpService.php
View file @
7918e2fb
...
...
@@ -11,6 +11,7 @@ namespace Aegir\Provision\Service;
//require_once DRUSH_BASE_PATH . '/commands/core/rsync.core.inc';
use
Aegir\Provision\Service
;
use
Aegir\Provision\ServiceInterface
;
use
Aegir\Provision\ServiceSubscription
;
use
Consolidation\AnnotatedCommand\CommandFileDiscovery
;
...
...
@@ -19,7 +20,7 @@ use Consolidation\AnnotatedCommand\CommandFileDiscovery;
*
* @package Aegir\Provision\Service
*/
class
HttpService
extends
Service
{
class
HttpService
extends
Service
implements
ServiceInterface
{
const
SERVICE
=
'http'
;
const
SERVICE_NAME
=
'Web Server'
;
...
...
@@ -57,7 +58,7 @@ class HttpService extends Service {
*
* This is used to allow skipping of the service restart.
*/
function
verify
Provid
er
()
function
verify
Serv
er
()
{
return
[
'configuration'
=>
$this
->
writeConfigurations
(),
...
...
@@ -67,14 +68,18 @@ class HttpService extends Service {
/**
* React to the `provision verify` command on Server contexts
*/
function
verifyS
ubscription
(
ServiceSubscription
$serviceSubscription
)
{
$this
->
subscription
=
$
service
Subscription
;
function
verifyS
ite
(
)
{
$this
->
subscription
=
$
this
->
getContext
()
->
get
Subscription
()
;
return
[
'configuration'
=>
$this
->
writeConfigurations
(
$
serviceS
ubscription
),
'configuration'
=>
$this
->
writeConfigurations
(
$
this
->
s
ubscription
),
'service'
=>
$this
->
restartService
(),
];
}
//
function
verifyPlatform
()
{
}
//
// /**
// * Support the ability to cloak the database credentials using environment variables.
// */
...
...
src/ServiceInterface.php
0 → 100644
View file @
7918e2fb
<?php
namespace
Aegir\Provision
;
interface
ServiceInterface
{
/**
* Triggered on `provision verify` command on Site contexts.
*/
public
function
verifySite
();
/**
* Triggered on `provision verify` command on Platform contexts.
*/
public
function
verifyPlatform
();
/**
* Triggered on `provision verify` command on Site contexts.
*/
public
function
verifyServer
();
}
\ No newline at end of file
src/ServiceSubscription.php
View file @
7918e2fb
...
...
@@ -9,6 +9,7 @@
namespace
Aegir\Provision
;
use
Aegir\Provision\Common\ContextAwareTrait
;
use
Aegir\Provision\Common\ProvisionAwareTrait
;
class
ServiceSubscription
{
...
...
@@ -20,22 +21,23 @@ class ServiceSubscription {
public
$properties
=
[];
use
ProvisionAwareTrait
;
use
ContextAwareTrait
;
function
__construct
(
Context
$context
,
$server
,
$service_name
)
{
$this
->
context
=
$context
;
$this
->
server
=
Provision
::
getContext
(
$server
,
$context
->
getProvision
());
$this
->
setContext
(
$context
);
$this
->
setProvision
(
$context
->
getProvision
());
$this
->
server
=
$this
->
getProvision
()
->
getContext
(
$server
);
$this
->
service
=
$this
->
server
->
getService
(
$service_name
);
$this
->
type
=
$this
->
server
->
getService
(
$service_name
)
->
type
;
if
(
isset
(
$context
->
config
[
'service_subscriptions'
][
$service_name
][
'properties'
]))
{
$this
->
properties
=
$context
->
config
[
'service_subscriptions'
][
$service_name
][
'properties'
];
}
$this
->
setProvision
(
$context
->
getProvision
());
}
public
function
verify
()
{
...
...
Prev
1
2
Next