AppserverIo\Appserver\Core\Api\AppService::undeploy PHP Method

undeploy() public method

Removes the .deployed flag file from the deploy folder, therefore the app will be undeployed with the next restart.
public undeploy ( AppserverIo\Appserver\Core\Api\Node\ContainerNodeInterface $containerNode, string $uuid ) : void
$containerNode AppserverIo\Appserver\Core\Api\Node\ContainerNodeInterface The container the app is bound to
$uuid string UUID of the application to delete
return void
    public function undeploy(ContainerNodeInterface $containerNode, $uuid)
    {
        // try to load the app node with the passe UUID
        if ($appNode = $this->load($uuid)) {
            // prepare file name
            $extractor = $this->getExtractor();
            $fileName = $appNode->getName() . $extractor->getExtensionSuffix();
            // load the file info
            $archive = new \SplFileInfo($this->getDeployDir($containerNode) . DIRECTORY_SEPARATOR . $fileName);
            // un-flag the archiv => un-deploy it with the next restart
            $extractor->unflagArchive($archive);
        }
    }

Usage Example

Example #1
0
 /**
  * If we can determine if a passed UUID is an invalid one
  *
  * @return null
  */
 public function testUndeployInvalidUuid()
 {
     $mockExtractor = $this->getMock('\\AppserverIo\\Appserver\\Core\\Interfaces\\ExtractorInterface');
     $mockExtractor->expects($this->never())->method('unflagArchive');
     $this->appService->injectExtractor($mockExtractor);
     $appNode = new AppNode(__METHOD__, '/opt/appserver/targetwebapp');
     $this->appService->undeploy($appNode->getUuid());
 }