rocketeers / rocketeer

Send your projects up in the clouds
http://rocketeer.autopergamene.eu/
MIT License
2.67k stars 217 forks source link

symlink deploy #323

Closed digitalbart closed 9 years ago

digitalbart commented 9 years ago

Hello,

I am trying to get current symlink to work in a non laravel app and it does not seem to be working.

Rocketeer::after('deploy', function($task) {

$current_release = $task->releasesManager->getCurrentReleasePath();
$task->command->info('Current Release: ' . $current_release);

# i tried this
$update_symlink = $task->updateSymlink();
   # and this 
$task->command->run(sprintf('ln -s %s %s', $current_folder, $current_release));
$task->command->info('updated symlink');     });
Anahkiasen commented 9 years ago

I'm not sure I get what you're trying to do, the symlink is done by Rocketeer internally, you don't have to do it yourself.

digitalbart commented 9 years ago

Thanks for the fast response. It does not create the symlink it should be in the same folder as releases correct? I tried a --verbose deploy and it does not showing anything unusual. I don't however see anything in the log either though, to indicate a symlink was created.

Anahkiasen commented 9 years ago

The current folder will actually be located one level up. Can you paste a log of your deployments?

digitalbart commented 9 years ago

Here is log:

$ mkdir /var/www/html/test/shared_folder mkdir: cannot create directory ‘/var/www/html/test/shared_folder’: File exists 20141013163033 20141013163716 20141013165250 20141013165923 20141013170016 20141013170527 20141013171452 20141013171553 20141013171815 20141013171909 20141013172346 20141013172752 20141013172946 20141014090252 20141014090500 20141014090522 20141014091311 20141014092853 20141014092934 20141014092951 20141014093046 20141014093145 20141014093451 20141014093615 20141014093653 20141014094200 20141014094254 20141014094346 20141014100707 20141014101126 20141014101219 20141014101543 20141014101616 $ git --version git version 1.9.1 git version 1.9.1 $ /usr/bin/php -m [PHP Modules] bcmath bz2 calendar Core ctype curl date dba dom ereg exif fileinfo filter ftp gd gettext hash iconv imagick intl json libxml mbstring mcrypt mhash mysql mysqli mysqlnd openssl pcntl pcre PDO pdo_mysql Phar posix readline Reflection session shmop SimpleXML soap sockets SPL standard sysvmsg sysvsem sysvshm tokenizer wddx xdebug xml xmlreader xmlwriter Zend OPcache zip zlib [Zend Modules] Xdebug Zend OPcache $ git clone "https://xxx:xxxxx@bitbucket.org/brianbarthold/tic-tac-toe.git" "/var/www/html/test/releases/20141014103553" --branch="master" --depth="1" Cloning into '/var/www/html/test/releases/20141014103553'... $ cd /var/www/html/test/releases/20141014103553 $ git submodule update --init --recursive

Anahkiasen commented 9 years ago

Hm it seems Rocketeer considers your server to not be setup and tries to do so but fails. Does it just, stop there ? Also what is the shared_folder it tries to created in the beginning, that's not from Rocketeer.

digitalbart commented 9 years ago

I was just trying to make a shared_folder since it was not working? I am not sure why it is not setup, I see the deploys and folders? Here is what I get when I run a deploy:

$ php bin/rocketeer deploy | Deploy (Deploys the website) [~4.38s] |-- Closure fired by deploy.before [~0.4s] check if shared folder exists shared folder = creating shared folder |=> Server is not ready, running Setup task |-- Setup (Set up the remote server for deployment) [~0.58s] |---- Check (Check if the server is ready to receive the application) [~0.58s] |------ Check/Php (Checks if the server is ready to receive a PHP application) |=====> Checking presence of git |=====> Checking presence of Composer |=====> Checking PHP version |=====> Checking presence of required extensions |=====> Checking presence of required drivers The Composer package manager could not be found |-- Primer (Run local checks to ensure deploy can proceed) |-- CreateRelease (Creates a new release on the server) [~2.72s] |---- Deploy/Clone (Clones a fresh instance of the repository by SCM) |===> Cloning repository in "/var/www/html/test/releases/20141014103553" |===> Initializing submodules if any |-- Dependencies (Installs or update the dependencies on server) [~1.18s] |---- Dependencies/Polyglot (Runs all of the above package managers if necessary) |-- Closure fired by deploy.after [~0.41s] Current Release: /var/www/html/test/releases/20141014103553 updated symlink The tasks queue was canceled by task "Deploy" Execution time: 4.8174s Saved logs to /var/www/html/app/Vendor/.rocketeer/logs/production--20141014.log

Anahkiasen commented 9 years ago

Can you run that again with the --verbose flag ? Rocketeer says the deployment failed

digitalbart commented 9 years ago

sure here it is:

$ php bin/rocketeer deploy --verbose | Deploy (Deploys the website) [~4.36s] |-- Closure fired by deploy.before [~0.39s] check if shared folder exists shared folder = $ mkdir /var/www/html/test/shared_folder vagrant@192.168.56.203 mkdir: cannot create directory ‘/var/www/html/test/shared_folder’: File exists creating shared folder |=> Server is not ready, running Setup task |-- Setup (Set up the remote server for deployment) [~0.58s] |---- Check (Check if the server is ready to receive the application) [~0.57s] |------ Check/Php (Checks if the server is ready to receive a PHP application) |=====> Checking presence of git $ git --version vagrant@192.168.56.203 git version 1.9.1 |=====> Checking presence of Composer |=====> Checking PHP version |=====> Checking presence of required extensions $ /usr/bin/php -m vagrant@192.168.56.203 [PHP Modules] bcmath bz2 calendar Core ctype curl date dba dom ereg exif fileinfo filter vagrant@192.168.56.203 ftp gd gettext hash iconv imagick intl json libxml mbstring mcrypt mhash mysql mysqli vagrant@192.168.56.203 mysqlnd openssl pcntl pcre PDO pdo_mysql Phar posix readline Reflection session shmop SimpleXML vagrant@192.168.56.203 soap vagrant@192.168.56.203 sockets vagrant@192.168.56.203 SPL vagrant@192.168.56.203 standard sysvmsg sysvsem sysvshm tokenizer wddx xdebug xml xmlreader xmlwriter Zend OPcache zip zlib vagrant@192.168.56.203 [Zend Modules] Xdebug Zend OPcache |=====> Checking presence of required drivers The Composer package manager could not be found |-- Primer (Run local checks to ensure deploy can proceed) |-- CreateRelease (Creates a new release on the server) [~2.7s] |---- Deploy/Clone (Clones a fresh instance of the repository by SCM) |===> Cloning repository in "/var/www/html/test/releases/20141014104539" $ git clone "https://xxx:xxxx@bitbucket.org/brianbarthold/tic-tac-toe.git" "/var/www/html/test/releases/20141014104539" --branch="master" --depth="1" vagrant@192.168.56.203 Cloning into '/var/www/html/test/releases/20141014104539'... |===> Initializing submodules if any $ cd /var/www/html/test/releases/20141014104539 $ git submodule update --init --recursive |-- Dependencies (Installs or update the dependencies on server) [~1.18s] |---- Dependencies/Polyglot (Runs all of the above package managers if necessary) |-- Closure fired by deploy.after [~0.4s] Current Release: /var/www/html/test/releases/20141014104539 updated symlink The tasks queue was canceled by task "Deploy" Execution time: 4.5238s Saved logs to /var/www/html/app/Vendor/.rocketeer/logs/production--20141014.log

Anahkiasen commented 9 years ago

Can you remove your symlink task before that ? It seems it's failing during that, see where it goes without it

digitalbart commented 9 years ago

sure here is the verbose again: I am still not seeing a current though

php bin/rocketeer deploy --verbose | Deploy (Deploys the website) [~4.31s] |-- Closure fired by deploy.before [~0.39s] check if shared folder exists shared folder = $ mkdir /var/www/html/test/shared_folder vagrant@192.168.56.203 mkdir: cannot create directory ‘/var/www/html/test/shared_folder’: File exists creating shared folder |=> Server is not ready, running Setup task |-- Setup (Set up the remote server for deployment) [~0.58s] |---- Check (Check if the server is ready to receive the application) [~0.57s] |------ Check/Php (Checks if the server is ready to receive a PHP application) |=====> Checking presence of git $ git --version vagrant@192.168.56.203 git version 1.9.1 |=====> Checking presence of Composer |=====> Checking PHP version |=====> Checking presence of required extensions $ /usr/bin/php -m vagrant@192.168.56.203 [PHP Modules] bcmath bz2 calendar Core ctype curl date dba dom ereg exif fileinfo filter vagrant@192.168.56.203 ftp gd gettext hash iconv imagick intl json libxml mbstring mcrypt mhash mysql mysqli mysqlnd vagrant@192.168.56.203 openssl pcntl pcre PDO pdo_mysql Phar posix readline Reflection session shmop SimpleXML vagrant@192.168.56.203 soap sockets SPL vagrant@192.168.56.203 standard sysvmsg sysvsem sysvshm vagrant@192.168.56.203 tokenizer wddx xdebug xml xmlreader vagrant@192.168.56.203 xmlwriter Zend OPcache zip vagrant@192.168.56.203 zlib

[Zend Modules] vagrant@192.168.56.203 Xdebug Zend OPcache |=====> Checking presence of required drivers The Composer package manager could not be found |-- Primer (Run local checks to ensure deploy can proceed) |-- CreateRelease (Creates a new release on the server) [~2.62s] |---- Deploy/Clone (Clones a fresh instance of the repository by SCM) |===> Cloning repository in "/var/www/html/test/releases/20141014105540" $ git clone "https://xxx:xxxx@bitbucket.org/brianbarthold/tic-tac-toe.git" "/var/www/html/test/releases/20141014105540" --branch="master" --depth="1" vagrant@192.168.56.203 Cloning into '/var/www/html/test/releases/20141014105540'... |===> Initializing submodules if any $ cd /var/www/html/test/releases/20141014105540 $ git submodule update --init --recursive |-- Dependencies (Installs or update the dependencies on server) [~1.18s] |---- Dependencies/Polyglot (Runs all of the above package managers if necessary) |-- Closure fired by deploy.after [~0.39s] Current Release: /var/www/html/test/releases/20141014105540 The tasks queue was canceled by task "Deploy" Execution time: 4.5154s Saved logs to /var/www/html/app/Vendor/.rocketeer/logs/production--20141014.log

Anahkiasen commented 9 years ago

It still seems to be executing something at Closure fired by deploy.after [~0.39s]. Do you have any more events you might have defined anywhere else?

digitalbart commented 9 years ago

Yes just echoing out the current version: I have a tasks.php which has this:

use Rocketeer\Facades\Rocketeer;

Rocketeer::before('deploy', function($task) {

$task->command->info('check if shared folder exists');

$shared_folder = $task->fileExists('shared_folder');

$task->command->info('shared folder = ' . $shared_folder);

if ($shared_folder):
    $task->command->info('folder already exists');
else:
    $task->createFolder('shared_folder');
    $task->command->info('creating shared folder');
endif;    

});

Rocketeer::after('deploy', function($task) {

$current_release = $task->releasesManager->getCurrentReleasePath();
$task->command->info('Current Release: ' . $current_release);

});

Anahkiasen commented 9 years ago

Try removing those two see if the deploy is able to proceed or if the problem is somewhere else ?

digitalbart commented 9 years ago

I did remove both and it still is not creating the symlink? Here is the verbose output and log below that:

$ php bin/rocketeer deploy --verbose | Deploy (Deploys the website) [~4.32s] |=> Server is not ready, running Setup task |-- Setup (Set up the remote server for deployment) [~0.57s] |---- Check (Check if the server is ready to receive the application) [~0.56s] |------ Check/Php (Checks if the server is ready to receive a PHP application) |=====> Checking presence of git $ git --version vagrant@192.168.56.203 git version 1.9.1 |=====> Checking presence of Composer |=====> Checking PHP version |=====> Checking presence of required extensions $ /usr/bin/php -m vagrant@192.168.56.203 [PHP Modules] bcmath bz2 calendar Core ctype curl date dba dom ereg exif fileinfo filter ftp vagrant@192.168.56.203 gd gettext hash iconv imagick intl json libxml mbstring mcrypt mhash vagrant@192.168.56.203 mysql mysqli mysqlnd openssl pcntl pcre PDO pdo_mysql Phar posix readline vagrant@192.168.56.203 Reflection session vagrant@192.168.56.203 shmop SimpleXML vagrant@192.168.56.203 soap sockets SPL standard vagrant@192.168.56.203 sysvmsg sysvsem sysvshm vagrant@192.168.56.203 tokenizer wddx xdebug xml xmlreader xmlwriter Zend OPcache zip zlib vagrant@192.168.56.203 [Zend Modules] Xdebug Zend OPcache |=====> Checking presence of required drivers The Composer package manager could not be found |-- Primer (Run local checks to ensure deploy can proceed) |-- CreateRelease (Creates a new release on the server) [~2.6s] |---- Deploy/Clone (Clones a fresh instance of the repository by SCM) |===> Cloning repository in "/var/www/html/test/releases/20141014111833" $ git clone "https://xxx:xxxx@bitbucket.org/brianbarthold/tic-tac-toe.git" "/var/www/html/test/releases/20141014111833" --branch="master" --depth="1" vagrant@192.168.56.203 Cloning into '/var/www/html/test/releases/20141014111833'... |===> Initializing submodules if any $ cd /var/www/html/test/releases/20141014111833 $ git submodule update --init --recursive |-- Dependencies (Installs or update the dependencies on server) [~1.16s] |---- Dependencies/Polyglot (Runs all of the above package managers if necessary) The tasks queue was canceled by task "Deploy" Execution time: 3.9779s Saved logs to /var/www/html/app/Vendor/.rocketeer/logs/production--20141014.log

logs output

20141013163033 20141013163716 20141013165250 20141013165923 20141013170016 20141013170527 20141013171452 20141013171553 20141013171815 20141013171909 20141013172346 20141013172752 20141013172946 20141014090252 20141014090500 20141014090522 20141014091311 20141014092853 20141014092934 20141014092951 20141014093046 20141014093145 20141014093451 20141014093615 20141014093653 20141014094200 20141014094254 20141014094346 20141014100707 20141014101126 20141014101219 20141014101543 20141014101616 20141014103553 20141014104539 20141014105507 20141014105540 20141014110746 20141014111505 $ git --version git --version git version 1.9.1 git version 1.9.1 $ /usr/bin/php -m /usr/bin/php -m [PHP Modules] bcmath bz2 calendar Core ctype curl date dba dom ereg exif fileinfo filter ftp gd gettext hash iconv imagick intl json libxml mbstring mcrypt mhash mysql mysqli mysqlnd openssl pcntl pcre PDO pdo_mysql Phar posix readline Reflection session shmop SimpleXML soap sockets SPL standard sysvmsg sysvsem sysvshm tokenizer wddx xdebug xml xmlreader xmlwriter Zend OPcache zip zlib [Zend Modules] Xdebug Zend OPcache $ git clone "https://xxx:xxxx@bitbucket.org/brianbarthold/tic-tac-toe.git" "/var/www/html/test/releases/20141014111833" --branch="master" --depth="1" git clone "https://xxx:xxxx@bitbucket.org/brianbarthold/tic-tac-toe.git" "/var/www/html/test/releases/20141014111833" --branch="master" --depth="1" Cloning into '/var/www/html/test/releases/20141014111833'... $ cd /var/www/html/test/releases/20141014111833 $ git submodule update --init --recursive cd /var/www/html/test/releases/20141014111833 git submodule update --init --recursive

Anahkiasen commented 9 years ago

I don't get it, why is it stopping like that abruptly. Are you able to clone the repository yourself on your server via those commands?

digitalbart commented 9 years ago

let me check, yes I am able to with this command: git clone "https://xxx:xxxx@bitbucket.org/brianbarthold/tic-tac-toe.git" "/var/www/html/test/releases/testclone" --branch="master" --depth="1"

Here is the output: Cloning into '/var/www/html/test/releases/testclone'... remote: Counting objects: 4, done. remote: Compressing objects: 100% (4/4), done. remote: Total 4 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (4/4), done. Checking connectivity... done.

and it does show in the releases directory

digitalbart commented 9 years ago

I was able to get this work, I am not sure if I am missing something on my server setup? I appreciate all your help. If you have any other suggestions let me know but this seems to work for now.

UPDATE: Turned out it was the strategies.php dependencies => 'Polygot'. I only had composer on the server, and once I switched that, it made it all the way to the end and it removed old deploys etc. Hope this helps anyone else if you are in the same boat.


Did work but had errors:

Rocketeer::after('deploy', function($task) {
$current_release = $task->releasesManager->getCurrentReleasePath();
$task->command->info('Current Release: ' . $current_release);
$current = "/var/www/html/test/current";
$task->run(sprintf('ln -s %s %s', $current_release, $current));
});
Anahkiasen commented 9 years ago

If you use $task->symlink does that work too ?