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.rc15 lib/fanforce/app_factory/cli/scripts/restart.rb
fanforce-app-factory-2.0.0.rc14 lib/fanforce/app_factory/cli/scripts/restart.rb
fanforce-app-factory-2.0.0.rc13 lib/fanforce/app_factory/cli/scripts/restart.rb
fanforce-app-factory-2.0.0.rc12 lib/fanforce/app_factory/cli/scripts/restart.rb
fanforce-app-factory-2.0.0.rc11 lib/fanforce/app_factory/cli/scripts/restart.rb
fanforce-app-factory-2.0.0.rc10 lib/fanforce/app_factory/cli/scripts/restart.rb
fanforce-app-factory-2.0.0.rc9 lib/fanforce/app_factory/cli/scripts/restart.rb