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

Still Requires Asset Pipeline on Server when not using the rails asset pipeline #117

Open
chrishough opened this issue Aug 31, 2016 · 3 comments

Comments

@chrishough
Copy link

Fixed Locally here: #111

Now the server is not working. Thoughts?

screen shot 2016-08-31 at 11 09 21 am

@chrishough
Copy link
Author

chrishough commented Aug 31, 2016

I just tried this as a fix :

  config.serve_static_files   = true
  config.static_cache_control = 'public, max-age=3600'

with no luck as that tosses a 404 via NGINX and trying this: https://github.com/heroku/rails_serve_static_assets

@chrishough
Copy link
Author

chrishough commented Sep 1, 2016

This is how I fixed this.. but there has to be a better way...

... and it still does not capture everything...

I, [2016-08-31T19:36:31.466663 #19541]  INFO -- : method=GET path=/resque/ format=html controller=ResqueWeb::OverviewController action=show status=200 duration=131.28 view=131.02 db=0.00 time=2016-08-31 19:36:31 -0500 params={} host= source=
F, [2016-08-31T19:36:31.718184 #19603] FATAL -- :
ActionController::RoutingError (No route matches [GET] "/assets/resque_web/poll-2138e7c844e6f8d2c14d4e39384744827ed3e6cc4574045a6f72bf8df13e11a8.png"):
  actionpack (4.2.6) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
  actionpack (4.2.6) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  lograge (0.4.1) lib/lograge/rails_ext/rack/logger.rb:15:in `call_app'
  railties (4.2.6) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.2.6) lib/active_support/tagged_logging.rb:68:in `block in tagged'
  activesupport (4.2.6) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.2.6) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.2.6) lib/rails/rack/logger.rb:20:in `call'
  actionpack (4.2.6) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
  rack (1.6.4) lib/rack/runtime.rb:18:in `call'
  rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
  actionpack (4.2.6) lib/action_dispatch/middleware/ssl.rb:24:in `call'
  railties (4.2.6) lib/rails/engine.rb:518:in `call'
  railties (4.2.6) lib/rails/application.rb:165:in `call'
  unicorn (5.1.0) lib/unicorn/http_server.rb:562:in `process_client'
  unicorn (5.1.0) lib/unicorn/http_server.rb:658:in `worker_loop'
  unicorn (5.1.0) lib/unicorn/http_server.rb:508:in `spawn_missing_workers'
  unicorn (5.1.0) lib/unicorn/http_server.rb:132:in `start'
  unicorn (5.1.0) bin/unicorn:126:in `<top (required)>'
  /home/deploy/whiplash_app/shared/bundle/ruby/2.3.0/bin/unicorn:23:in `load'
  /home/deploy/whiplash_app/shared/bundle/ruby/2.3.0/bin/unicorn:23:in `<main>'

deploy.rb

  desc 'Resque Assets'
  task :assets do
    on roles(:app), in: :sequence, wait: 5 do
      within(release_path) do
        with rails_env: fetch(:rails_env) do
          execute :rake, 'assets:precompile', '--trace'
          execute :rake, 'resque:assets:setup', '--trace'
        end
      end
    end
  end
 after 'deploy:finished', 'deploy:assets'

resque.rake

require 'resque/tasks'
require 'resque/scheduler/tasks'

# FYI: https://github.com/resque/resque-scheduler
# FYI: https://gist.github.com/snatchev/1316470
# FYI: http://stackoverflow.com/questions/2611747/rails-resque-workers-fail-with-pgerror-server-closed-the-connection-unexpectedl
namespace :resque do
  desc 'Setup Resque'
  task setup: :environment do
    require 'resque'
    # Resque.redis : Configured in config/initializers/resque.rb
    ENV['QUEUE'] ||= '*'
  end

  task setup_schedule: :setup do
    require 'resque-scheduler'
    Resque.schedule = YAML.load_file('resque_schedule.yml')
  end

  task scheduler: :setup_schedule

  namespace :cache do
    desc 'Clears Rails cache'
    task clear: :environment do
      Rails.cache.clear
    end
  end

  namespace :assets do
    desc 'Fix Resque Web Assets as a Microservice'
    task setup: :environment do
      assets = Dir.glob(File.join(Rails.root, 'public/assets/**/*'))
      regex = /(-{1}[a-z0-9]{32}*\.{1}){1}/
      assets.each do |file|
        next if File.directory?(file) || file !~ regex

        source = file.split('/')
        source.push(source.pop.gsub(regex, '.'))

        non_digested = File.join(source)
        FileUtils.mv(file, non_digested)
      end

      new_asset_path = "#{Rails.root}/public"
      FileUtils.mkdir("#{new_asset_path}/images")
      FileUtils.mkdir("#{new_asset_path}/stylesheets")
      FileUtils.mkdir("#{new_asset_path}/javascripts")
      FileUtils.mkdir("#{new_asset_path}/images/resque_web")
      FileUtils.mkdir("#{new_asset_path}/stylesheets/resque_web")
      FileUtils.mkdir("#{new_asset_path}/javascripts/resque_web")
      FileUtils.mv(Dir.glob("#{Rails.root}/public/assets/**/*.png"), "#{new_asset_path}/images/resque_web/")
      FileUtils.mv(Dir.glob("#{Rails.root}/public/assets/**/*.js"), "#{new_asset_path}/javascripts/resque_web/")
      FileUtils.mv(Dir.glob("#{Rails.root}/public/assets/**/*.js.gz"), "#{new_asset_path}/javascripts/resque_web/")
      FileUtils.mv(Dir.glob("#{Rails.root}/public/assets/**/*.css"), "#{new_asset_path}/stylesheets/resque_web/")
      FileUtils.mv(Dir.glob("#{Rails.root}/public/assets/**/*.css.gz"), "#{new_asset_path}/stylesheets/resque_web/")

      FileUtils.mv(Dir.glob("#{Rails.root}/public/assets/**/*.svg"), new_asset_path)
      FileUtils.mv(Dir.glob("#{Rails.root}/public/assets/**/*.svg.gz"), new_asset_path)
      FileUtils.mv(Dir.glob("#{Rails.root}/public/assets/**/*.eot"), new_asset_path)
      FileUtils.mv(Dir.glob("#{Rails.root}/public/assets/**/*.eot.gz"), new_asset_path)
      FileUtils.mv(Dir.glob("#{Rails.root}/public/assets/**/*.ttf"), new_asset_path)
      FileUtils.mv(Dir.glob("#{Rails.root}/public/assets/**/*.ttf.gz"), new_asset_path)
      FileUtils.mv(Dir.glob("#{Rails.root}/public/assets/**/*.woff"), new_asset_path)
      FileUtils.rm_rf("#{new_asset_path}/assets")
    end
  end
end

@wjessop
Copy link

wjessop commented Oct 21, 2020

This still seems to be broken for me on Rails 6:

ActionView::Template::Error (The asset "resque_web/application.css" is not present in the asset pipeline.

     6:   <meta name="description" content="">
     7:   <meta name="viewport" content="width=device-width">
     8:   <title>Resque.</title>
     9:   <%= stylesheet_link_tag "resque_web/application", :media => "all" %>
    10:   <%=
    11:       ResqueWeb::Plugins.plugins.collect do |p|
    12:         file_path = "#{p.name.underscore.downcase}/application.css"

sprockets-rails (3.2.2) lib/sprockets/rails/helper.rb:84:in `compute_asset_path'
actionview (6.0.3.4) lib/action_view/helpers/asset_url_helper.rb:201:in `asset_path'
actionview (6.0.3.4) lib/action_view/helpers/asset_url_helper.rb:346:in `stylesheet_path'
actionview (6.0.3.4) lib/action_view/helpers/asset_tag_helper.rb:143:in `block in stylesheet_link_tag'
actionview (6.0.3.4) lib/action_view/helpers/asset_tag_helper.rb:142:in `map'
actionview (6.0.3.4) lib/action_view/helpers/asset_tag_helper.rb:142:in `stylesheet_link_tag'
sprockets-rails (3.2.2) lib/sprockets/rails/helper.rb:186:in `block in stylesheet_link_tag'
sprockets-rails (3.2.2) lib/sprockets/rails/helper.rb:184:in `map'
sprockets-rails (3.2.2) lib/sprockets/rails/helper.rb:184:in `stylesheet_link_tag'
resque-web (0.0.12) app/views/layouts/resque_web/application.html.erb:9
actionview (6.0.3.4) lib/action_view/base.rb:274:in `_run'

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

No branches or pull requests

2 participants