spohlenz / tinymce-rails

Integration of TinyMCE with the Rails asset pipeline
Other
816 stars 258 forks source link

Tinymce assets files deleted in cap deploy:cleanup task #83

Closed akicho8 closed 11 years ago

akicho8 commented 11 years ago

When it's environment capistrano >= 2.14.0, tinymce files will be deleted in deploy:cleanup (assets:deploy:clean_expired). What cause a copy of the tinymce js for that is later than ran deploy:assets:update_asset_mtimes ?

deploy:

    triggering after callbacks for `deploy:update_code'
  * 2013-01-11 15:32:32 executing `deploy:assets:precompile'
    triggering before callbacks for `deploy:assets:precompile'
  * 2013-01-11 15:32:32 executing `deploy:assets:update_asset_mtimes'
  * executing "[ -e /var/www/myapp/shared/assets/manifest.yml ] && cat /var/www/myapp/shared/assets/manifest.yml || echo"
    servers: ["localhost"]
    [localhost] executing command
    command finished in 251ms
  * executing "ls -x /var/www/myapp/releases"
    servers: ["localhost"]
    [localhost] executing command
    command finished in 253ms
  * executing "cd -- /var/www/myapp/releases/20130111063140 && bundle exec rake RAILS_ENV=staging RAILS_GROUPS=assets assets:precompile && cp -- /var/www/myapp/shared/assets/manifest.yml /var/www/myapp/releases/20130111063140/assets_manifest.yml"
    servers: ["localhost"]
    [localhost] executing command
*** [err :: localhost] mkdir -p /private/var/www/myapp/releases/20130111063140/public/assets
*** [err :: localhost] cp -rp /private/var/www/myapp/shared/bundle/ruby/1.9.1/gems/tinymce-rails-3.5.8/vendor/assets/javascripts/tinymce /private/var/www/myapp/releases/20130111063140/public/assets

cleanup:

$ cap deploy:cleanup
    triggering load callbacks
    triggering start callbacks for `deploy:cleanup'
  * 2013-01-11 15:53:03 executing `multistage:ensure'
  * 2013-01-11 15:53:03 executing `deploy:cleanup'
  * executing "ls -xt /var/www/myapp/releases"
    servers: ["localhost"]
    [localhost] executing command
    command finished in 285ms
*** no old releases to clean up
    triggering after callbacks for `deploy:cleanup'
  * 2013-01-11 15:53:03 executing `deploy:assets:clean_expired'
  * executing "for manifest in /var/www/myapp/releases/*/assets_manifest.yml; do cat -- \"$manifest\" 2> /dev/null && printf ':::' || true; done"
    servers: ["localhost"]
    [localhost] executing command
    command finished in 277ms
 ** Fetched 1 manifests from /var/www/myapp/releases/*/assets_manifest.yml
 ** Writing required assets to /var/www/myapp/REQUIRED_ASSETS...
    servers: ["localhost"]
 ** sftp upload #<StringIO:0x007fc66b836880> -> /var/www/myapp/REQUIRED_ASSETS
    [localhost] /var/www/myapp/REQUIRED_ASSETS
    [localhost] done
  * sftp upload complete
 ** Removing assets that haven't been deployed for 0 minutes...
  * executing "cd -- /var/www/myapp/shared/assets/ && for f in $( find * -mmin +0 -type f | LC_COLLATE=C sort | LC_COLLATE=C comm -23 -- - /var/www/myapp/REQUIRED_ASSETS ); do echo \"Removing unneeded asset: $f\"; rm -f -- \"$f\"; done; rm -f -- /var/www/myapp/REQUIRED_ASSETS"
    servers: ["localhost"]
    [localhost] executing command
 ** [out :: localhost] Removing unneeded asset: tinymce/jquery.tinymce.js
 ** [out :: localhost] Removing unneeded asset: tinymce/langs/en.js
 ** [out :: localhost] Removing unneeded asset: tinymce/plugins/advhr/css/advhr.css
(snip)
spohlenz commented 11 years ago

tinymce-rails doesn't add the majority of TinyMCE JS or CSS files to the manifest (since they are copied over separately from the normal asset precompilation) which causes Capistrano's cleanup task to consider it unused.

I will look into some options here, most likely adding the files to the manifest. However Sprockets is changing to JSON manifests which complicates things slightly.

For now I'd recommend doing a manual recompile after cleaning up the assets folder.

gfrancesco commented 11 years ago

Same here, thanks

dsalzr commented 11 years ago

Great gem. Thank you for your work. I unfortunately had to stop using it due to this issue.

What I ended up doing was just copying the TinyMCE files to public/js and changing the "basepath" option in tinymce to /js/tinymce. No copying/compiling required that way on deploys.

spohlenz commented 11 years ago

I've created a new branch at https://github.com/spohlenz/tinymce-rails/tree/update-manifest which updates the asset manifest when copying the TinyMCE assets over. Could you give it a try and see if it solves the issue?

scarver2 commented 11 years ago

The update_manifest branch is working nicely with with cap deploy:cleanup.

There is a related thread at discussing the assets cleanup affect on TinyMCE https://github.com/capistrano/capistrano/issues/353#issuecomment-13973639

tompesman commented 11 years ago

@spohlenz the branch https://github.com/spohlenz/tinymce-rails/tree/update-manifest fixes the problem for me. Any plans in merging back and releasing this in the gem?

Thanks!

spohlenz commented 11 years ago

Thanks @tompesman. It looks like all of the feedback has been positive so far, so there'll probably be a new release in the next day or two.

I've just finished working on Rails 4 support today, so if anyone feels like testing that (same update-manifest branch) it would be greatly appreciated, although I'm not sure if capistrano or asset_sync are supporting it yet.

spohlenz commented 11 years ago

Hopefully all fixed in the latest gem release 3.5.8.1.

akicho8 commented 11 years ago

I was no longer removed was tested in ver 3.5.8.1. Thank you.

$ cap deploy:assets:clean_expired
  * 2013-03-01 22:34:36 executing `deploy:assets:clean_expired'
  * executing "for manifest in /var/www/myapp/releases/*/assets_manifest.yml; do cat -- \"$manifest\" 2> /dev/null && printf ':::' || true; done"
    servers: ["localhost"]
    [localhost] executing command
    command finished in 258ms
 ** Fetched 2 manifests from /var/www/myapp/releases/*/assets_manifest.yml
 ** Writing required assets to /var/www/myapp/REQUIRED_ASSETS...
    servers: ["localhost"]
 ** sftp upload #<StringIO:0x007fba9331ca90> -> /var/www/myapp/REQUIRED_ASSETS
    [localhost] /var/www/myapp/REQUIRED_ASSETS
    [localhost] done
  * sftp upload complete
 ** Removing assets that haven't been deployed for 0 minutes...
  * executing "cd -- /var/www/myapp/shared/assets/ && for f in $( find * -mmin +0 -type f | LC_COLLATE=C sort | LC_COLLATE=C comm -23 -- - /var/www/myapp/REQUIRED_ASSETS ); do echo \"Removing unneeded asset: $f\"; rm -f -- \"$f\"; done; rm -f -- /var/www/myapp/REQUIRED_ASSETS"
    servers: ["localhost"]
    [localhost] executing command
    command finished in 231ms
ansonhoyt commented 11 years ago

This worked for us. Thanks!