Introduction
Introduction Statistics Contact Development Disclaimer Help
Further Rails 5 fixes (#6) - warvox - VoIP based wardialing tool, forked from r…
Log
Files
Refs
README
---
commit 735babd824962bd6c2664864c3fcf73d58e00b86
parent 9255728b51c007552219a73e2b6ad18b05486480
Author: Chee Yeo <[email protected]>
Date: Sat, 15 Oct 2016 08:38:57 +0100
Further Rails 5 fixes (#6)
* Fix bin/warvox to accept arguments which are passed to bin/rails, which is th…
* Fix errors of "can't be called from trap context" by wrapping trap blocks wit…
* Exclude certain files from docker builds
* Move config/environments/production.rb to original version
* Add more notes about assets to README.md
Diffstat:
A .dockerignore | 3 +++
M .gitignore | 1 +
M Gemfile | 2 +-
M Gemfile.lock | 10 +++-------
M README.md | 78 ++++++++++++++++++++++-------…
A bin/warvox | 102 +++++++++++++++++++++++++++++…
D bin/warvox.rb | 104 -----------------------------…
M bin/worker_manager.rb | 4 ++--
M config/environments/production.rb | 99 +++++++++++++++++++----------…
9 files changed, 229 insertions(+), 174 deletions(-)
---
diff --git a/.dockerignore b/.dockerignore
@@ -0,0 +1,3 @@
+.git
+.env
+.dockerignore
diff --git a/.gitignore b/.gitignore
@@ -31,3 +31,4 @@ playbook.retry
TODO.md
/public/assets
+.env
diff --git a/Gemfile b/Gemfile
@@ -1,6 +1,6 @@
source 'https://rubygems.org'
-gem 'unicorn'
+gem 'puma'
gem 'rails', '~> 5.0', '>= 5.0.0.1'
gem 'pg', '~> 0.18'
diff --git a/Gemfile.lock b/Gemfile.lock
@@ -163,7 +163,6 @@ GEM
jsobfu (0.4.1)
rkelly-remix (= 0.0.6)
json (2.0.2)
- kgio (2.10.0)
kissfft (0.0.2)
launchy (2.4.3)
addressable (~> 2.3)
@@ -200,6 +199,7 @@ GEM
method_source (~> 0.8.1)
slop (~> 3.4)
psych_shield (0.0.4)
+ puma (3.6.0)
rack (2.0.1)
rack-test (0.6.3)
rack (>= 1.0)
@@ -229,7 +229,6 @@ GEM
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
- raindrops (0.17.0)
rake (11.2.2)
rb-fsevent (0.9.7)
rb-inotify (0.9.7)
@@ -305,9 +304,6 @@ GEM
thread_safe (~> 0.1)
uglifier (3.0.2)
execjs (>= 0.3.0, < 3)
- unicorn (5.1.0)
- kgio (~> 2.6)
- raindrops (~> 0.7)
web-console (3.3.1)
actionview (>= 5.0)
activemodel (>= 5.0)
@@ -353,6 +349,7 @@ DEPENDENCIES
pg (~> 0.18)
pry
psych_shield
+ puma
rails (~> 5.0, >= 5.0.0.1)
rails-settings-cached (>= 0.4.1)
rails_layout
@@ -366,10 +363,9 @@ DEPENDENCIES
therubyracer
tzinfo-data
uglifier (>= 1.3.0)
- unicorn
web-console
will_paginate (~> 3.0)
will_paginate-bootstrap
BUNDLED WITH
- 1.12.5
+ 1.13.4
diff --git a/README.md b/README.md
@@ -9,45 +9,52 @@ Questions and suggestions can be sent to:
- [Installing](#installing)
-##installing
+## Installing
WarVOX requires a Linux operating system, preferably Ubuntu or Debian.
WarVOX requires PostgreSQL 9.1 or newer with the "contrib" package installed f…
To get started, install the OS-level dependencies:
-
- $ sudo apt-get install gnuplot lame build-essential libssl-dev libcurl…
+```
+ $ sudo apt-get install gnuplot lame build-essential libssl-dev libcurl…
postgresql postgresql-contrib postgresql-common git-core curl libpq-…
+```
Install RVM to obtain Ruby 2.2.5 or later
-
+```
$ \curl -L https://get.rvm.io | bash -s stable --autolibs=3 --rails
+```
After RVM is installed you need to run the rvm script provided
-
+```
$ source /usr/local/rvm/scripts/rvm
+```
In case you have not installed Ruby 2.2.5 or later by now, do so using RVM.
-
+```
$ rvm install ruby-2.2.5
-
-Clone this repository to the location you want to install WarVOX:
+```
+Clone this repository to the location you want to install WarVOX:
+```
$ git clone git://github.com/rapid7/warvox.git /opt/warvox
+```
Configure WarVOX:
-
+```
$ cd /opt/warvox
$ bundle install
$ make
+```
Verify your installation:
-
+```
$ bin/verify_install.rb
+```
Configure the PostgreSQL account for WarVOX:
-
+```
$ sudo su - postgres
$ createuser -s warvox
$ createdb warvox -O warvox
@@ -55,38 +62,63 @@ Configure the PostgreSQL account for WarVOX:
psql> alter user warvox with password 'randompass';
psql> exit
$ exit
+```
Copy the example database configuration to database.yml:
-
+```
$ cp config/database.yml.example config/database.yml
+```
Copy the example secrets configuration to secrets.yml:
-
+```
$ cp config/secrets.yml.example config/secrets.yml
-
-Create a new secrect token:
-
+```
+Create a new secrect token:
+```
$ rake secret > config/session.key
-
+```
Modify config/database.yml to include the password set previously
Initialize the WarVOX database:
-
+```
$ make database
+```
Add an admin account to WarVOX
-
+```
$ bin/adduser admin randompass
+```
Start the WarVOX daemons:
-
- $ bin/warvox.rb
+```
+ $ bin/warvox
+```
or to bind WarVox to all interfaces:
-
- $ bin/warvox.rb --address 0.0.0.0
+```
+ $ bin/warvox --address 0.0.0.0
+```
Access the web interface at http://127.0.0.1:7777/
At this point you can configure a new IAX2 provider, create a project, and sta…
+## Assets
+
+To get assets to show up, you need to first compile assets in production envir…
+
+```
+RAILS_ENV=production bundle exec rake assets:precompile
+```
+This will compile all static assets into `public` folder.
+
+Next, you need to enable the `RAILS_SERVE_STATIC_FILES` environment variable t…
+
+```
+export RAILS_SERVE_STATIC_FILES=true
+```
+or wrap the above in a `.env` file and run source:
+
+```
+source .env
+```
diff --git a/bin/warvox b/bin/warvox
@@ -0,0 +1,102 @@
+#!/usr/bin/env ruby
+###################
+
+require 'getoptlong'
+require 'open3'
+
+#
+# Load the library path
+#
+base = __FILE__
+while File.symlink?(base)
+ base = File.expand_path(File.readlink(base), File.dirname(base))
+end
+
+$:.unshift(File.join(File.expand_path(File.dirname(base)), '..', 'lib'))
+
+voxroot = File.expand_path(File.join(File.dirname(base), '..'))
+manager = File.expand_path(File.join(File.dirname(base), 'worker_manager.rb'))
+
+require 'warvox'
+
+
+Dir.chdir(voxroot)
+
+def stop
+ $stderr.puts "[-] Interrupt received, shutting down workers and web server..…
+ Process.kill("TERM", @manager_pid) if @manager_pid
+ exit(0)
+end
+
+def usage
+ $stderr.puts "#{$0} [--address IP] [--port PORT] --background"
+ exit(0)
+end
+
+opts =
+{
+ 'ServerPort' => 7777,
+ 'ServerHost' => '127.0.0.1',
+ 'Background' => false,
+}
+
+args = GetoptLong.new(
+ ["--address", "-a", GetoptLong::REQUIRED_ARGUMENT ],
+ ["--port", "-p", GetoptLong::REQUIRED_ARGUMENT ],
+ ["--daemon", "-d", GetoptLong::NO_ARGUMENT ],
+ ["--help", "-h", GetoptLong::NO_ARGUMENT]
+)
+
+args.each do |opt,arg|
+ case opt
+ when '--address'
+ opts['ServerHost'] = arg
+ when '--port'
+ opts['ServerPort'] = arg
+ when '--daemon'
+ opts['Background'] = true
+ when '--help'
+ usage()
+ end
+end
+
+args = [
+ 'server',
+ '-p', opts['ServerPort'].to_s,
+ '-b', opts['ServerHost'],
+ '-e', 'production',
+]
+
+if opts['Background']
+ args.push("-d")
+end
+
+
+trap("SIGINT") { Thread.new{ stop } }
+
+$browser_url = "http://#{opts['ServerHost']}:#{opts['ServerPort']}/"
+
+WarVOX::Log.info("")
+WarVOX::Log.info("[*] Starting WarVOX on #{$browser_url}")
+WarVOX::Log.info("")
+WarVOX::Log.info("WarVOX is starting up...")
+
+@manager_pid = Process.fork()
+if not @manager_pid
+ while ARGV.shift do
+ end
+ load(manager)
+ exit(0)
+end
+
+WarVOX::Log.info("Worker Manager has PID #{@manager_pid}")
+
+@webserver_pid = $$
+
+WarVOX::Log.info("Web Server has PID #{@webserver_pid}")
+
+while(ARGV.length > 0); ARGV.shift; end
+args.each {|arg| ARGV.push(arg) }
+
+# need to pass config opts above into the system command below
+system "bin/rails", *args
diff --git a/bin/warvox.rb b/bin/warvox.rb
@@ -1,104 +0,0 @@
-#!/usr/bin/env ruby
-###################
-
-require 'getoptlong'
-require 'open3'
-
-#
-# Load the library path
-#
-base = __FILE__
-while File.symlink?(base)
- base = File.expand_path(File.readlink(base), File.dirname(base))
-end
-
-$:.unshift(File.join(File.expand_path(File.dirname(base)), '..', 'lib'))
-
-voxroot = File.expand_path(File.join(File.dirname(base), '..'))
-voxserv = File.expand_path(File.join(File.expand_path(voxroot), 'bin', 'rails'…
-manager = File.expand_path(File.join(File.dirname(base), 'worker_manager.rb'))
-
-require 'warvox'
-
-
-Dir.chdir(voxroot)
-
-def stop
- $stderr.puts "[-] Interrupt received, shutting down workers and web server..…
- Process.kill("TERM", @manager_pid) if @manager_pid
- exit(0)
-end
-
-def usage
- $stderr.puts "#{$0} [--address IP] [--port PORT] --background"
- exit(0)
-end
-
-opts =
-{
- 'ServerPort' => 7777,
- 'ServerHost' => '127.0.0.1',
- 'Background' => false,
-}
-
-args = GetoptLong.new(
- ["--address", "-a", GetoptLong::REQUIRED_ARGUMENT ],
- ["--port", "-p", GetoptLong::REQUIRED_ARGUMENT ],
- ["--daemon", "-d", GetoptLong::NO_ARGUMENT ],
- ["--help", "-h", GetoptLong::NO_ARGUMENT]
-)
-
-args.each do |opt,arg|
- case opt
- when '--address'
- opts['ServerHost'] = arg
- when '--port'
- opts['ServerPort'] = arg
- when '--daemon'
- opts['Background'] = true
- when '--help'
- usage()
- end
-end
-
-args = [
- 'server',
- '-p', opts['ServerPort'].to_s,
- '-b', opts['ServerHost'],
- '-e', 'production',
-]
-
-if opts['Background']
- args.push("-d")
-end
-
-
-trap("SIGINT") { stop() }
-
-$browser_url = "http://#{opts['ServerHost']}:#{opts['ServerPort']}/"
-
-$stderr.puts ""
-$stderr.puts "[*] Starting WarVOX on #{$browser_url}"
-$stderr.puts ""
-
-
-WarVOX::Log.info("WarVOX is starting up...")
-
-@manager_pid = Process.fork()
-if not @manager_pid
- while ARGV.shift do
- end
- load(manager)
- exit(0)
-end
-
-WarVOX::Log.info("Worker Manager has PID #{@manager_pid}")
-
-@webserver_pid = $$
-
-WarVOX::Log.info("Web Server has PID #{@manager_pid}")
-
-while(ARGV.length > 0); ARGV.shift; end
-args.each {|arg| ARGV.push(arg) }
-
-load(voxserv)
diff --git a/bin/worker_manager.rb b/bin/worker_manager.rb
@@ -161,8 +161,8 @@ end
# Main
#
-trap("SIGINT") { stop() }
-trap("SIGTERM") { stop() }
+trap("SIGINT") { Thread.new{ stop } }
+trap("SIGTERM") { Thread.new{ stop } }
@cookie = Socket.gethostname + "^" + $$.to_s + "^" + sprintf("%.8x", rand(0x…
@max_jobs = 3
diff --git a/config/environments/production.rb b/config/environments/production…
@@ -1,56 +1,81 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/applicat…
- # In the development environment your application's code is reloaded on
- # every request. This slows down response time but is perfect for development
- # since you don't have to restart the web server when you make code changes.
- config.cache_classes = false
+ # Code is not reloaded between requests.
+ config.cache_classes = true
- # Do not eager load code on boot.
- config.eager_load = false
+ # Eager load code on boot. This eager loads most of Rails and
+ # your application in memory, allowing both threaded web servers
+ # and those relying on copy on write to perform better.
+ # Rake tasks automatically ignore this option for performance.
+ config.eager_load = true
- # Show full error reports and disable caching.
- config.consider_all_requests_local = true
+ # Full error reports are disabled and caching is turned on.
+ config.consider_all_requests_local = false
+ config.action_controller.perform_caching = true
- # Enable/disable caching. By default caching is disabled.
- if Rails.root.join('tmp/caching-dev.txt').exist?
- config.action_controller.perform_caching = true
+ # Disable serving static files from the `/public` folder by default since
+ # Apache or NGINX already handles this.
+ config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
- config.cache_store = :memory_store
- config.public_file_server.headers = {
- 'Cache-Control' => 'public, max-age=172800'
- }
- else
- config.action_controller.perform_caching = false
+ # Compress JavaScripts and CSS.
+ config.assets.js_compressor = :uglifier
+ # config.assets.css_compressor = :sass
- config.cache_store = :null_store
- end
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
+ config.assets.compile = false
- # Don't care if the mailer can't send.
- config.action_mailer.raise_delivery_errors = false
+ # `config.assets.precompile` and `config.assets.version` have moved to confi…
- config.action_mailer.perform_caching = false
+ # Enable serving of images, stylesheets, and JavaScripts from an asset serve…
+ # config.action_controller.asset_host = 'http://assets.example.com'
- # Print deprecation notices to the Rails logger.
- config.active_support.deprecation = :log
+ # Specifies the header that your server uses for sending files.
+ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
- # Raise an error on page load if there are pending migrations.
- config.active_record.migration_error = :page_load
+ # Force all access to the app over SSL, use Strict-Transport-Security, and u…
+ # config.force_ssl = true
+ # Use the lowest log level to ensure availability of diagnostic information
+ # when problems arise.
config.log_level = :debug
- # Debug mode disables concatenation and preprocessing of assets.
- # This option may cause significant delays in view rendering with a large
- # number of complex assets.
- config.assets.debug = false
+ # Prepend all log lines with the following tags.
+ config.log_tags = [ :request_id ]
+
+ # Use a different cache store in production.
+ # config.cache_store = :mem_cache_store
+
+ # Use a real queuing backend for Active Job (and separate queues per environ…
+ # config.active_job.queue_adapter = :resque
+ # config.active_job.queue_name_prefix = "barerails5app_#{Rails.env}"
+ config.action_mailer.perform_caching = false
+
+ # Ignore bad email addresses and do not raise email delivery errors.
+ # Set this to true and configure the email server for immediate delivery to …
+ # config.action_mailer.raise_delivery_errors = false
+
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
+ # the I18n.default_locale when a translation cannot be found).
+ config.i18n.fallbacks = true
+
+ # Send deprecation notices to registered listeners.
+ config.active_support.deprecation = :notify
- # Suppress logger output for asset requests.
- config.assets.quiet = true
+ # Use default logging formatter so that PID and timestamp are not suppressed.
+ config.log_formatter = ::Logger::Formatter.new
- # Raises error for missing translations
- # config.action_view.raise_on_missing_translations = true
+ # Use a different logger for distributed setups.
+ # require 'syslog/logger'
+ # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-n…
+
+ if ENV["RAILS_LOG_TO_STDOUT"].present?
+ logger = ActiveSupport::Logger.new(STDOUT)
+ logger.formatter = config.log_formatter
+ config.logger = ActiveSupport::TaggedLogging.new(logger)
+ end
- # Use an evented file watcher to asynchronously detect changes in source cod…
- # routes, locales, etc. This feature depends on the listen gem.
- # config.file_watcher = ActiveSupport::EventedFileUpdateChecker
+ # Do not dump schema after migrations.
+ config.active_record.dump_schema_after_migration = false
end
You are viewing proxied material from jay.scot. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.