-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php | ||
/* (c) Anton Medvedev <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Deployer\Initializer\Template; | ||
|
||
/** | ||
* Generate a node.js deployer configuration. | ||
* | ||
* @author Anton Medvedev <[email protected]> | ||
*/ | ||
class NodeJsTemplate extends Template | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
protected function getTemplateContent() | ||
{ | ||
return <<<PHP | ||
<?php | ||
/* | ||
* This file has been generated automatically. | ||
* Please change the configuration for correct use deploy. | ||
*/ | ||
require 'recipe/common.php'; | ||
// Set configurations | ||
set('repository', '[email protected]:username/repository.git'); | ||
set('shared_files', []); | ||
set('shared_dirs', []); | ||
set('writable_dirs', []); | ||
// Configure servers | ||
server('production', 'prod.domain.com') | ||
->user('username') | ||
->password() | ||
->env('deploy_path', '/var/www/prod.domain.com'); | ||
server('beta', 'beta.domain.com') | ||
->user('username') | ||
->password() | ||
->env('deploy_path', '/var/www/beta.domain.com'); | ||
/** | ||
* Install npm packages. | ||
*/ | ||
task('deploy:npm', function () { | ||
\$releases = env('releases_list'); | ||
if (isset(\$releases[1])) { | ||
if(run("if [ -d {{deploy_path}}/releases/{\$releases[1]}/node_modules ]; then echo 'true'; fi")->toBool()) { | ||
run("cp --recursive {{deploy_path}}/releases/{\$releases[1]}/node_modules {{release_path}}"); | ||
} | ||
} | ||
run("cd {{release_path}} && npm install"); | ||
}); | ||
/** | ||
* Restart server on success deploy. | ||
*/ | ||
task('pm2:restart', function () { | ||
run("pm2 restart eightd"); | ||
})->desc('Restart pm2 service'); | ||
after('success', 'pm2:restart'); | ||
/** | ||
* Main task | ||
*/ | ||
task('deploy', [ | ||
'deploy:prepare', | ||
'deploy:release', | ||
'deploy:update_code', | ||
'deploy:shared', | ||
'deploy:writable', | ||
'deploy:npm', | ||
'deploy:symlink', | ||
'cleanup', | ||
])->desc('Deploy your project'); | ||
after('deploy', 'success'); | ||
PHP; | ||
} | ||
} |