Sha256: d30ba9f7834a60ef7b6ac72b45e75c5b53d7e30082e4b9f9f0241f55b034fe5c

Contents?: true

Size: 1.67 KB

Versions: 27

Compression:

Stored size: 1.67 KB

Contents

class Fanforce::AppFactory::CLI::Scripts
  include Fanforce::AppFactory::CLI::Utils

  ######################################################################################################################

  def restart(environment=:development)
    environment = environment.to_sym

    if Fanforce::CLI::TYPE == :directory_of_apps
      Fanforce::CLI::Apps.each do |app, current_count, total|
        restart_app(app, environment)
      end
    else
      restart_app(Fanforce::CLI::App.load(Fanforce::CLI::DIR), environment)
    end
    log divider '----------------------------------------------------------------------------------------------------++'
  end

  def restart_app(app, environment)
    log divider '------------------------------------------------------------------------------------------------------'
    environments = environment==:all ? [:development,:staging,:production] : [environment]
    Dir.chdir(app.dir) do
      environments.each do |environment|
        if environment == :development
          FileUtils.mkdir("#{app.dir}/tmp") if !File.directory?("#{app.dir}/tmp")
          FileUtils.touch("#{app.dir}/tmp/restart.txt")
        elsif [:production, :staging].include?(environment)
          error 'Production and Staging are not working'
          if config[:heroku].blank? or config[:heroku][environment].blank?
            puts "#{'OOPS...'.format(:red,:bold)} #{environment} has not been setup on heroku"
            next
          end
          heroku = auth_heroku(environment)
          heroku.post_ps_restart get_heroku_app_name(app, environment)
        end
        log "#{"Restarted #{environment}".format(:bold,:green)} #{app.dir_name}"
      end
    end
  end

end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
fanforce-app-factory-2.0.0.rc36 lib/fanforce/app_factory/cli/scripts/restart.rb
fanforce-app-factory-2.0.0.rc35 lib/fanforce/app_factory/cli/scripts/restart.rb
fanforce-app-factory-2.0.0.rc34 lib/fanforce/app_factory/cli/scripts/restart.rb
fanforce-app-factory-2.0.0.rc33 lib/fanforce/app_factory/cli/scripts/restart.rb
fanforce-app-factory-2.0.0.rc32 lib/fanforce/app_factory/cli/scripts/restart.rb
fanforce-app-factory-2.0.0.rc31 lib/fanforce/app_factory/cli/scripts/restart.rb
fanforce-app-factory-2.0.0.rc30 lib/fanforce/app_factory/cli/scripts/restart.rb
fanforce-app-factory-2.0.0.rc29 lib/fanforce/app_factory/cli/scripts/restart.rb
fanforce-app-factory-2.0.0.rc27 lib/fanforce/app_factory/cli/scripts/restart.rb
fanforce-app-factory-2.0.0.rc26 lib/fanforce/app_factory/cli/scripts/restart.rb
fanforce-app-factory-2.0.0.rc25 lib/fanforce/app_factory/cli/scripts/restart.rb
fanforce-app-factory-2.0.0.rc24 lib/fanforce/app_factory/cli/scripts/restart.rb
fanforce-app-factory-2.0.0.rc23 lib/fanforce/app_factory/cli/scripts/restart.rb
fanforce-app-factory-2.0.0.rc22 lib/fanforce/app_factory/cli/scripts/restart.rb
fanforce-app-factory-2.0.0.rc21 lib/fanforce/app_factory/cli/scripts/restart.rb
fanforce-app-factory-2.0.0.rc20 lib/fanforce/app_factory/cli/scripts/restart.rb
fanforce-app-factory-2.0.0.rc19 lib/fanforce/app_factory/cli/scripts/restart.rb
fanforce-app-factory-2.0.0.rc18 lib/fanforce/app_factory/cli/scripts/restart.rb
fanforce-app-factory-2.0.0.rc17 lib/fanforce/app_factory/cli/scripts/restart.rb
fanforce-app-factory-2.0.0.rc16 lib/fanforce/app_factory/cli/scripts/restart.rb