Class: SimplePerf::CLI::StartCustom

Inherits:
Object
  • Object
show all
Includes:
Shared
Defined in:
lib/simple_perf/cli/start_custom.rb

Instance Method Summary collapse

Methods included from Shared

pretty_print

Instance Method Details

#executeObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/simple_perf/cli/start_custom.rb', line 8

def execute
  opts = Trollop::options do
    version SimplePerf::VERSION
    banner <<-EOS

Starts JMeter or Gatling with custom shell script.

Usage:
simple_perf start_custom -e ENVIRONMENT -p PROJECT_NAME
EOS
    opt :help, "Display Help"
    opt :environment, "Set the target environment", :type => :string
    opt :project, "Project name to manage", :type => :string
  end
  Trollop::die :environment, "is required but not specified" unless opts[:environment]
  Trollop::die :project, "is required but not specified" unless opts[:project]

  config = Config.new.environment opts[:environment]

  ENV['SIMPLE_DEPLOY_SSH_KEY'] = config['local_pem']
  ENV['SIMPLE_DEPLOY_SSH_USER'] = config['user']

  command = 'simple_deploy execute' +
              ' -e ' + opts[:environment] +
              ' -n ' + 'simple-perf-' + opts[:project] +
              ' -c "cd ~/simple_perf_test_files; nohup ./start_custom.sh 2>&1 start_custom.log  &"' +
              ' -l debug -x'

  Shared::pretty_print `#{command}`
end