Author: Tim Wagner (tw@appserver.io)
Inheritance: extends Thread, implements AppserverIo\Appserver\Core\Interfaces\ApplicationServerInterface
Ejemplo n.º 1
0
$namingDirectory->createSubdirectory('php:env/args');
$namingDirectory->createSubdirectory('php:global');
$namingDirectory->createSubdirectory('php:global/log');
$namingDirectory->createSubdirectory('php:services');
// create the default subdirectories
foreach (array_keys(ApplicationServer::$runlevels) as $runlevel) {
    $namingDirectory->createSubdirectory(sprintf('php:services/%s', $runlevel));
}
// bind the command line arguments to the naming directory
foreach ($arguments as $name => $value) {
    $namingDirectory->bind(sprintf('php:env/args/%s', $name), empty($value) ? true : $value);
}
// bind the current user to the naming directory
$namingDirectory->bind('php:env/currentUser', isset($_SERVER['SUDO_USER']) ? $_SERVER['SUDO_USER'] : get_current_user());
// bind the path to the default configuration and bootstrap filenames
$namingDirectory->bind('php:env/configurationFilename', DirectoryKeys::realpath($filename));
$namingDirectory->bind('php:env/bootstrapConfigurationFilename', DirectoryKeys::realpath($bootstrapFilename));
// add the storeage containers for the runlevels
$runlevels = new GenericStackable();
foreach (ApplicationServer::$runlevels as $runlevel) {
    $runlevels[$runlevel] = new GenericStackable();
}
// initialize and start the application server
$applicationServer = new ApplicationServer($namingDirectory, $runlevels);
$applicationServer->start();
// we've to wait for shutdown
while ($applicationServer->keepRunning()) {
    sleep(1);
}
// wait until all threads have been stopped
$applicationServer->join();
Ejemplo n.º 2
0
$namingDirectory->createSubdirectory('php:env');
$namingDirectory->createSubdirectory('php:env/args');
$namingDirectory->createSubdirectory('php:global');
$namingDirectory->createSubdirectory('php:global/log');
$namingDirectory->createSubdirectory('php:services');
// create the default subdirectories
foreach (array_keys(ApplicationServer::$runlevels) as $runlevel) {
    $namingDirectory->createSubdirectory(sprintf('php:services/%s', $runlevel));
}
// bind the command line arguments to the naming directory
foreach ($arguments as $name => $value) {
    $namingDirectory->bind(sprintf('php:env/args/%s', $name), empty($value) ? true : $value);
}
// bind the current user to the naming directory
$namingDirectory->bind('php:env/currentUser', isset($_SERVER['SUDO_USER']) ? $_SERVER['SUDO_USER'] : get_current_user());
// bind the path to the default configuration and bootstrap filenames
$namingDirectory->bind('php:env/configurationFilename', DirectoryKeys::realpath($filename));
$namingDirectory->bind('php:env/bootstrapConfigurationFilename', DirectoryKeys::realpath($bootstrapFilename));
// add the storeage containers for the runlevels
$runlevels = new GenericStackable();
foreach (ApplicationServer::$runlevels as $runlevel) {
    $runlevels[$runlevel] = new GenericStackable();
}
// initialize and start the application server
$applicationServer = ApplicationServer::singleton($namingDirectory, $runlevels);
// we've to wait for shutdown
while ($applicationServer->keepRunning()) {
    sleep(1);
}
// wait until all threads have been stopped
$applicationServer->join();
Ejemplo n.º 3
0
 /**
  * Creates a new singleton application server instance.
  *
  * @param \AppserverIo\Psr\Naming\NamingDirectoryInterface $configurationFilename The default naming directory
  * @param \AppserverIo\Storage\GenericStackable            $runlevels             The storage for the services
  *
  * @return \AppserverIo\Appserver\Core\Interfaces\ApplicationServerInterface The singleton application instance
  */
 public static function singleton(NamingDirectoryInterface $namingDirectory, GenericStackable $runlevels)
 {
     // query whether we already have an instance or not
     if (ApplicationServer::$instance == null) {
         // initialize and start the application server
         ApplicationServer::$instance = new ApplicationServer($namingDirectory, $runlevels);
         ApplicationServer::$instance->start();
     }
     // return the instance
     return ApplicationServer::$instance;
 }