Class: Ronin::App::CLI Private
- Inherits:
-
Core::CLI::Command
- Object
- Core::CLI::Command
- Ronin::App::CLI
- Includes:
- CommandKit::OpenApp, CommandKit::Options::Version, Core::CLI::Logging
- Defined in:
- lib/ronin/app/cli.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Starts the ronin web app.
Usage
ronin-app [options]
Options
-V, --version Prints the version and exits
-H, --host IP The host to listen on (Default: localhost)
--db NAME The ronin-db database to connect to
--db-uri URI The ronin-db database URI to connect to
-p, --port PORT The port to listen on (Default: 1337)
-h, --help Print help information
Instance Method Summary collapse
-
#app_env ⇒ Hash{String => String}
private
The environment variables Hash for the app processes.
-
#is_redis_running? ⇒ Boolean
private
Determines if the Redis server is running.
-
#run ⇒ Object
private
Runs the
ronin-app
command. -
#start_redis ⇒ Integer
private
Starts the Redis server.
-
#start_sidekiq ⇒ Integer
private
Starts the sidekiq background job process.
-
#start_web_server ⇒ Integer
private
Starts the web server process.
Instance Method Details
#app_env ⇒ Hash{String => String}
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The environment variables Hash for the app processes.
183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/ronin/app/cli.rb', line 183 def app_env env = {} if [:db_uri] env['DATABASE_URL'] = [:db_uri] elsif [:db] env['DATABASE_NAME'] = [:db].to_s end return env end |
#is_redis_running? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Determines if the Redis server is running.
140 141 142 |
# File 'lib/ronin/app/cli.rb', line 140 def is_redis_running? !`pgrep redis-server`.empty? end |
#run ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Runs the ronin-app
command.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/ronin/app/cli.rb', line 96 def run host = [:host] port = [:port] pids = [] # switch to the app directory Dir.chdir(ROOT) begin unless is_redis_running? log_info "Starting Redis server ..." pids << start_redis sleep 1 end # start the web server process log_info "Starting Web server on #{host}:#{port} ..." pids << start_web_server sleep 1 # start the sidekiq process log_info "Starting Sidekiq ..." pids << start_sidekiq sleep 1 open_app_for("http://#{host}:#{port}") if stdout.tty? sleep ensure pids.each do |pid| Process.kill('TERM',pid) Process.kill('HUP',pid) end Process.waitall end end |
#start_redis ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Starts the Redis server.
150 151 152 |
# File 'lib/ronin/app/cli.rb', line 150 def start_redis Process.spawn('redis-server') end |
#start_sidekiq ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Starts the sidekiq background job process.
173 174 175 |
# File 'lib/ronin/app/cli.rb', line 173 def start_sidekiq Process.spawn(app_env,"sidekiq -C ./config/sidekiq.yml -e production -r ./config/sidekiq.rb -r ./workers.rb") end |
#start_web_server ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Starts the web server process.
160 161 162 163 164 165 |
# File 'lib/ronin/app/cli.rb', line 160 def start_web_server command = %w[puma -C ./config/puma.rb -e production] command << '-b' << "tcp://#{[:host]}:#{[:port]}" Process.spawn(app_env,*command) end |