middleman-deploy icon indicating copy to clipboard operation
middleman-deploy copied to clipboard

Don't run livereload when deploying.

Open ghost opened this issue 11 years ago • 16 comments

When I run 'middleman deploy', it seems to run LiveReload when I use middleman-livereload in a project.

ghost avatar Dec 22 '13 00:12 ghost

Could you paste a copy of your config.rb here please?

tvaughan avatar Dec 23 '13 19:12 tvaughan

require "json"
require "slim"
require "coffee-script"
require "uglifier"

Slim::Engine.set_default_options :pretty => true

Time.zone = "Pacific Time (US & Canada)"

set :css_dir, 'css'
set :js_dir, 'js'
set :images_dir, 'images'
set :fonts_dir, 'fonts'

set :markdown_engine, :redcarpet
set :markdown, :fenced_code_blocks => true,
               :autolink => true, 
               :smartypants => true

page "humans.txt", :layout => false
page "robots.txt", :layout => false
page "/errors/404.html", :layout => false

activate :directory_indexes
activate :livereload

class FixPermissions < Middleman::Extension
  def initialize(app, options_hash={}, &block)
    super
    app.after_build do |builder|
      builder.run 'chmod 644 build/images/*'
      builder.run 'chmod 644 build/css/*'
      builder.run 'chmod 644 build/js/*'
    end
  end
end

::Middleman::Extensions.register(:fix_perm, FixPermissions)

configure :build do
  # Prep Assets for Caching
  activate :asset_hash
  activate :asset_host
  set :asset_host, "//cdn.rbg.io"

  # Minify Text
  activate :minify_css
  activate :minify_javascript

  # Compress Images
  activate :imageoptim

  # Fix Permissions
  activate :fix_perm
end

activate :deploy do |deploy|
  #deploy.build_before = true
  deploy.method = :rsync
  deploy.clean = true

  deploy.user  = ""
  deploy.port  =
  deploy.host  = ""
  deploy.path  = ""
end

ghost avatar Dec 23 '13 19:12 ghost

Thanks!

Hm. Any idea how the "build" method turns that off? Or does it run during that too?

tvaughan avatar Dec 23 '13 19:12 tvaughan

It doesn't run during the build method. Unfortunately, I have no idea how it works, though.

ghost avatar Dec 23 '13 19:12 ghost

I'm running into the same thing.

reneruiz avatar Jan 03 '14 13:01 reneruiz

Maybe you need to talk to the middleman-livereload guy to have it not run if it's not :development rather than if build don't do anything.

https://codeclimate.com/github/middleman/middleman-livereload/Middleman::LiveReloadExtension

ghost avatar Jan 20 '14 00:01 ghost

Supposedly this has been resolved by https://github.com/middleman/middleman-livereload/issues/41. Can someone else confirm this? Thanks @roundedbygravity !

tvaughan avatar Feb 23 '14 14:02 tvaughan

I updated my middleman-livereload gem and I'm still seeing it on deploy. Others seem to also:

https://github.com/middleman/middleman-livereload/issues/41

I've even changed my config to call it this way and no dice:

configure :development do activate :livereload end

ghost avatar Mar 07 '14 16:03 ghost

With middleman-core (3.2.2) and middleman-livereload (3.2.1), even wrapping the LiveReload activation in a configure :development block still runs LiveReload during deployment.

paulozoom avatar Mar 11 '14 10:03 paulozoom

I am seeing the same issue, anyone find a way to fix this

chrishough avatar Jul 20 '14 17:07 chrishough

Same problem here

baires avatar Jan 05 '15 21:01 baires

I'm creating an extension to auto-open a browser window to the live reload URL in dev, and I'm seeing the same thing for my extension that you guys see for live reload. I even check to make sure the environment isn't the dev environment out of paranoia and the browser is still opened twice. (doing all the right things like only activating the plugin during dev, etc). Similar to live reload, I don't see this issue occurring during the build command, only during the deploy command.

Snipit of my paranoia:

    app.ready do |builder|
      return unless app.environment == :development
      Launchy.open("http://0.0.0.0:4567")
    end

parrots avatar Mar 01 '15 20:03 parrots

I get the same thing and my activate :livereload is declared within a configure :development do block inside my config.rb. Commenting it out got around the issue but it's not ideal

tgdev avatar Apr 02 '15 14:04 tgdev

Having a similar problem when trying to access Middleman::PreviewServer properties in the development configuration block.

By the looks of it, this is due to how options are retrieved through Middleman Deploy's CLI.

https://github.com/middleman-contrib/middleman-deploy/blob/master/lib/middleman-deploy/commands.rb#L62

options = ::Middleman::Application.server.inst.options

::Middleman::Application.server.inst then triggers

mm.run_hook :ready

Which will trigger the configuration block.

I'm kind of new to Ruby so I haven't looked into actually fixing it but this ticket in Middleman's repo may be relevant: https://github.com/middleman/middleman/issues/781

Here's my stacktrace:

/home/jahed/projects/jahed-io/site/config.rb:26:in `block in initialize': uninitialized constant Middleman::PreviewServer (NameError)
        from /home/jahed/.gem/ruby/gems/uber-0.0.13/lib/uber/options.rb:80:in `instance_exec'
        from /home/jahed/.gem/ruby/gems/uber-0.0.13/lib/uber/options.rb:80:in `proc!'
        from /home/jahed/.gem/ruby/gems/uber-0.0.13/lib/uber/options.rb:69:in `evaluate_for'
        from /home/jahed/.gem/ruby/gems/uber-0.0.13/lib/uber/options.rb:60:in `evaluate'
        from /home/jahed/.gem/ruby/gems/hooks-0.4.0/lib/hooks/hook.rb:53:in `execute_callback'
        from /home/jahed/.gem/ruby/gems/hooks-0.4.0/lib/hooks/hook.rb:40:in `block in run'
        from /home/jahed/.gem/ruby/gems/hooks-0.4.0/lib/hooks/hook.rb:39:in `each'
        from /home/jahed/.gem/ruby/gems/hooks-0.4.0/lib/hooks/hook.rb:39:in `inject'
        from /home/jahed/.gem/ruby/gems/hooks-0.4.0/lib/hooks/hook.rb:39:in `run'
        from /home/jahed/.gem/ruby/gems/hooks-0.4.0/lib/hooks.rb:55:in `run_hook_for'
        from /home/jahed/.gem/ruby/gems/hooks-0.4.0/lib/hooks/instance_hooks.rb:6:in `run_hook'
        from /home/jahed/.gem/ruby/gems/middleman-core-3.3.12/lib/middleman-core/core_extensions/extensions.rb:166:in `initialize'
        from /home/jahed/.gem/ruby/gems/middleman-core-3.3.12/lib/middleman-core/core_extensions/data.rb:33:in `initialize'
        from /home/jahed/.gem/ruby/gems/middleman-core-3.3.12/lib/middleman-core/application.rb:204:in `initialize'
        from /home/jahed/.gem/ruby/gems/middleman-core-3.3.12/lib/middleman-core/core_extensions/request.rb:56:in `new'
        from /home/jahed/.gem/ruby/gems/middleman-core-3.3.12/lib/middleman-core/core_extensions/request.rb:56:in `inst'
        from /home/jahed/.gem/ruby/gems/middleman-deploy-1.0.0/lib/middleman-deploy/commands.rb:62:in `deploy_options'
        from /home/jahed/.gem/ruby/gems/middleman-deploy-1.0.0/lib/middleman-deploy/commands.rb:36:in `build_before'
        from /home/jahed/.gem/ruby/gems/middleman-deploy-1.0.0/lib/middleman-deploy/commands.rb:29:in `deploy'
        from /home/jahed/.gem/ruby/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
        from /home/jahed/.gem/ruby/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
        from /home/jahed/.gem/ruby/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
        from /home/jahed/.gem/ruby/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
        from /home/jahed/.gem/ruby/gems/middleman-core-3.3.12/lib/middleman-core/cli.rb:72:in `method_missing'
        from /home/jahed/.gem/ruby/gems/thor-0.19.1/lib/thor/command.rb:29:in `run'
        from /home/jahed/.gem/ruby/gems/thor-0.19.1/lib/thor/command.rb:126:in `run'
        from /home/jahed/.gem/ruby/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
        from /home/jahed/.gem/ruby/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
        from /home/jahed/.gem/ruby/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
        from /home/jahed/.gem/ruby/gems/middleman-core-3.3.12/lib/middleman-core/cli.rb:20:in `start'
        from /home/jahed/.gem/ruby/gems/middleman-core-3.3.12/bin/middleman:18:in `<top (required)>'
        from /home/jahed/bin/middleman:23:in `load'
        from /home/jahed/bin/middleman:23:in `<main>'

jahed avatar Jun 19 '15 00:06 jahed

Does activate :livereload need to be moved into a :development configuration?

configure :development do
  activate :livereload
end

robertwbradford avatar Sep 30 '15 16:09 robertwbradford

@robertwbradford We're doing that already. You can find the config.rb we're using here:

https://github.com/unruly/unruly.github.io/blob/develop/config.rb

jahed avatar Oct 04 '15 01:10 jahed