Skip to content
This repository has been archived by the owner on Feb 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #46 from Smart-Core/master
Browse files Browse the repository at this point in the history
timeout Process support
  • Loading branch information
dizda committed Jan 23, 2015
2 parents 6b5a571 + 227e176 commit b1ae087
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
15 changes: 14 additions & 1 deletion Databases/BaseDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ abstract class BaseDatabase

protected $dataPath;
protected $filesystem;
protected $timeout;

/**
* Get SF2 Filesystem
Expand All @@ -26,6 +27,7 @@ public function __construct($basePath)
{
$this->dataPath = $basePath . static::DB_PATH . '/';
$this->filesystem = new Filesystem();
$this->timeout = 300;
}

/**
Expand All @@ -37,7 +39,7 @@ public function __construct($basePath)
*/
protected function execute($command)
{
$process = new Process($command);
$process = new Process($command, null, null, null, $this->timeout);
$process->run();

if (!$process->isSuccessful()) {
Expand All @@ -53,6 +55,17 @@ protected function preparePath()
$this->filesystem->mkdir($this->dataPath);
}

/**
* @param int $timeout
* @return $this
*/
public function setTimeout($timeout)
{
$this->timeout = $timeout;

return $this;
}

/**
* Migration procedure for each databases type
*
Expand Down
1 change: 1 addition & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function getConfigTreeBuilder()
$rootNode
->children()
->scalarNode('output_file_prefix')->defaultValue(gethostname())->end()
->scalarNode('timeout')->defaultValue(300)->end()
->arrayNode('processor')
->addDefaultsIfNotSet()
->children()
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ Here is the default configuration for the bundle:
dizda_cloud_backup:
# By default backup files will have your servers hostname as prefix
# such as: hostname_2014-01-01_21-08-39.tar
output_file_prefix: hostname
output_file_prefix: hostname
timeout: 300
processor:
type: tar # Required: tar|zip|7z
options:
Expand Down
8 changes: 7 additions & 1 deletion Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,24 @@ services:
arguments:
- %dizda_cloud_backup.databases%
- %dizda_cloud_backup.output_folder%
calls:
- [ setTimeout, [ %dizda_cloud_backup.timeout% ] ]

dizda.cloudbackup.database.mysql:
class: Dizda\CloudBackupBundle\Databases\MySQL
arguments:
- %dizda_cloud_backup.databases%
- %dizda_cloud_backup.output_folder%
calls:
- [ setTimeout, [ %dizda_cloud_backup.timeout% ] ]

dizda.cloudbackup.database.postgresql:
class: Dizda\CloudBackupBundle\Databases\PostgreSQL
arguments:
- %dizda_cloud_backup.databases%
- %dizda_cloud_backup.output_folder%
calls:
- [ setTimeout, [ %dizda_cloud_backup.timeout% ] ]

dizda.cloudbackup.processor.tar:
class: Dizda\CloudBackupBundle\Processors\TarProcessor
Expand All @@ -60,4 +66,4 @@ services:
- %dizda_cloud_backup.output_folder%
- %dizda_cloud_backup.output_file_prefix%
- %dizda_cloud_backup.folders%
- %dizda_cloud_backup.processor%
- %dizda_cloud_backup.processor%

0 comments on commit b1ae087

Please sign in to comment.