Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rsync strategy for final deployment #106

Merged
merged 6 commits into from
Apr 4, 2016

Conversation

mblaschke
Copy link
Contributor

Add possibility to sync (via rsync) files to current-directorty instead of symlink because of opcode-caching issues which are not always solvable (eg. shared hosting or customer hosted servers).

It's not an atomic deployment but better than dealing with symlink issues for such environments.
Still using releases/... will provide a possibility to run migrations before deploying the code to current directory so it's still better than just running rsync to web directory.

Default is still symlink but it can be changed with ansistrano_current_via="rsync".

file: state=directory path={{ ansistrano_deploy_to }}/{{ ansistrano_current_dir }}

- name: ANSISTRANO | Sync release to new current path
command: rsync -a --copy-links --delete-after "{{ ansistrano_release_path.stdout }}/" "{{ ansistrano_deploy_to }}/{{ ansistrano_current_dir }}/"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you had a look at trying to achieve this using the synchronize module?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed :)

@ricardclau
Copy link
Member

Thanks for this contribution! Looks great apart from the synchronize module detail I mentioned

We will need to update the docs as well but generally speaking 👍

@@ -11,6 +11,9 @@ ansistrano_version_dir: "releases"
# Softlink name for the current release
ansistrano_current_dir: "current"

# Current directorty deployment strategy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TYPO here, "directorty"

@ricardclau
Copy link
Member

I was looking at some docs, assuming your symlink problem is happening with PHP, have you checked if doing and after-symlink step running

php -r "clearstatcache();"

would do the trick?

@mblaschke
Copy link
Contributor Author

You can't clear the realpath-cache and opcode from cli, you have to clear it inside apache (mod_php) or fpm. But as long as requests are running the opcode cache is filled with old code so you have to stop/restart the webserver/fpm.

The only solution for symlink deployments is using nginx with fastcgi_param DOCUMENT_ROOT $realpath_root; or using mod_realdoc for apache. But both isn't possible in each environment.
see comments from rlerdorf: zendtech/ZendOptimizerPlus#126

This is also an issue for other languages

@ricardclau
Copy link
Member

Yeah, an option which I have done in the past is to do a curl to an internal url to achieve the same thing as this php -r command is doing in either Apache or Nginx. Nasty stuff indeed!

Thanks for the quick updates, it does not break anything so I am ok with it. @carlosbuenosvinos @theUniC ?

@carlosbuenosvinos
Copy link
Member

I think it makes sense. Give me this afternoon to take a look closer.

@mblaschke
Copy link
Contributor Author

We've tried a workaround with 10 serial curl requests with opcode-clear.php but it doesn't help. On busy sites the opcode cache is still buggy and many users are getting HTTP 500.

@ricardclau
Copy link
Member

Yeah, ideally you need to take the box of the Load Balancer, wait for the running requests to stop, deploy code, clear caches and add them again to the Load Balancer once everything is fine.

Surely easier said than done in many environments :(

@mblaschke
Copy link
Contributor Author

@carlosbuenosvinos
Found any issues? I've fixed merge ability.

@carlosbuenosvinos
Copy link
Member

With Ansible 1.9 is not working. Please check the log:
https://travis-ci.org/ansistrano/deploy/builds/120408282

2016-04-03 12:39 GMT+02:00 Markus Blaschke [email protected]:

@carlosbuenosvinos https://github.com/carlosbuenosvinos
Found any issues? I've fixed merge ability.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#106 (comment)

Carlos Buenosvinos Zamora
[email protected]
659730605

url: http://carlosbuenosvinos.com
twitter: buenosvinos
skype: carlos.buenosvinos
gtalk: [email protected]

@ricardclau
Copy link
Member

I think if you rebase master back it and change the regexp as I did in shared-symlink.yml it should work

@mblaschke
Copy link
Contributor Author

Fixed

@@ -105,6 +105,7 @@ Role Variables
ansistrano_deploy_to: "/var/www/my-app" # Base path to deploy to.
ansistrano_version_dir: "releases" # Releases folder name
ansistrano_current_dir: "current" # Softlink name. You should rarely changed it.
ansistrano_current_via: "symlink" # Deployment strategy who code should be deployed to current path. Options are symlink or rsync
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment should say something as "Deployment strategy about how code should be deployed to current path.

@carlosbuenosvinos
Copy link
Member

I would include some information into de readme. But I'm ok.

@carlosbuenosvinos carlosbuenosvinos merged commit 75b1ce6 into ansistrano:master Apr 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants