Skip to content

Commit

Permalink
Merge pull request #438 from wagnert/master
Browse files Browse the repository at this point in the history
Fixed error when prepared directories to be created on startup
  • Loading branch information
wagnert committed Feb 2, 2015
2 parents 9284f1b + ff4fe10 commit 292d12f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 8 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
* Fixed MQ memory leak because of missing job thread when handling messages
* Fixed invalid namespace in QueueManager::createSenderForQueue() method
* Remove unnecessary interfaces SenderInterface + ReceiverInterface
* minor bugfixes
* Fixed error when prepared directories to be created on startup
* Bugfix within service tests
* Minor bugfixes

## Features

* Refactoring, move interfaces of Persistence-Container + Message-Queue to separate packages
* Removed risk factor of non-injected \Stackable within class loader
* Applied new file name and coding conventions
* Updated dependencies
* Removed risk factor of non-injected \Stackable within class loader

# Version 1.0.0-beta4

Expand Down
17 changes: 13 additions & 4 deletions src/AppserverIo/Appserver/Core/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,22 +160,31 @@ protected function initInitialContext()
* Prepares filesystem to be sure that everything is on place as expected
*
* @return void
* @throws \Exception Is thrown if a server directory can't be created
*/
protected function initFileSystem()
{

// init API service to use
$service = $this->newService('AppserverIo\Appserver\Core\Api\ContainerService');

// load the directories
$directories = $service->getDirectories();

// check if the log directory already exists, if not, create it
foreach ($service->getDirectories() as $directory) {
foreach (DirectoryKeys::getServerDirectoryKeysToBeCreated() as $directoryKey) {

// prepare the path to the directory to be created
$toBeCreated = $service->realpath($directory);
$toBeCreated = $service->realpath($directories[$directoryKey]);

// prepare the directory name and check if the directory already exists
if (is_dir($toBeCreated) === false) {
// if not create it
mkdir($toBeCreated, 0755, true);
// if not, try to create it
if (mkdir($toBeCreated, 0755, true) === false) {
throw new \Exception(
sprintf('Can\'t create necessary directory %s while starting application server', $toBeCreated)
);
}
}
}
}
Expand Down
23 changes: 21 additions & 2 deletions src/AppserverIo/Appserver/Core/Utilities/DirectoryKeys.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,28 @@ private function __clone()
}

/**
* Returns the application servers directory keys.
* Returns the application servers directory keys for the directories that
* has to be created on startup.
*
* @return array The application server directory keys
* @return array The keys for the directories to be created on startup
*/
public static function getServerDirectoryKeysToBeCreated()
{
return array(
DirectoryKeys::WEBAPPS,
DirectoryKeys::TMP,
DirectoryKeys::DEPLOY,
DirectoryKeys::LOG,
DirectoryKeys::RUN,
DirectoryKeys::CONF,
DirectoryKeys::CONFD
);
}

/**
* Returns the all application servers directory keys.
*
* @return array All application server directory keys
*/
public static function getServerDirectoryKeys()
{
Expand Down

0 comments on commit 292d12f

Please sign in to comment.