Advertisement
Guest User

Untitled

a guest
May 27th, 2015
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. <?php
  2. require 'recipe/common.php';
  3.  
  4. /*
  5. * Servers
  6. */
  7.  
  8. // Set up production server
  9. server('production-server', 'host.com')
  10. ->user('root')
  11. ->path('/webroot/host.com');
  12.  
  13. // set up staging server
  14. server('staging-server', 'host.com')
  15. ->user('root')
  16. ->path('/webroot/host.com');
  17.  
  18. // set up stages
  19. stage('staging', ['staging-server'], ['branch' => 'master'], true);
  20. stage('production', ['production-server'], ['branch' => 'master']);
  21.  
  22. /*
  23. * Variables and settings
  24. */
  25. set('shared_dirs', ['storage']);
  26. set('shared_files', []);
  27. set('writable_dirs', ['storage']);
  28. set('permission_method', 'chmod_bad');
  29. set('repository', 'git repo');
  30.  
  31. /*
  32. * Tasks
  33. */
  34. task('deploy:copy_env', function () {
  35. $releasePath = env()->getReleasePath();
  36. run("cp current/.env $releasePath/");
  37. })->description('Copy .env files from previous release');
  38.  
  39. task('database:migrate', function () {
  40. run("php current/artisan migrate --force");
  41. })->description('Migrating database');
  42.  
  43. task('php-fpm:reload', function () {
  44. run("/usr/sbin/service php5-fpm reload");
  45. })->description('Reloading PHP5-FPM');
  46.  
  47.  
  48. task('deploy', [
  49. 'deploy:start',
  50. 'deploy:prepare',
  51. 'deploy:update_code',
  52. 'deploy:shared',
  53. 'deploy:writable_dirs',
  54. 'deploy:copy_env',
  55. 'deploy:vendors',
  56. 'deploy:symlink',
  57. 'database:migrate',
  58. 'cleanup',
  59. 'deploy:end'
  60. ])
  61. ->desc('Deploy your project')
  62. ->option('branch', 'b', 'Set the deployed branch', 'master');
  63.  
  64. /*
  65. * Hooks
  66. */
  67. // read branch from input option before getting code
  68. before('deploy:update_code', function ($input) {
  69. $stage = $input->getArgument('stage');
  70. if ($stage == 'staging' && $input->hasOption('branch')) {
  71. $branch = $input->getOption('branch', get('branch', null));
  72. set('branch', $branch);
  73. }
  74. });
  75.  
  76. // Reload php-fpm after deploy
  77. after('deploy:end', 'php-fpm:reload');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement