Skip to content
This repository has been archived by the owner on May 18, 2021. It is now read-only.

Commit

Permalink
Further Rails 5 fixes (#6)
Browse files Browse the repository at this point in the history

* Fix bin/warvox to accept arguments which are passed to bin/rails, which is the default in Rails 5
* Fix errors of "can't be called from trap context" by wrapping trap blocks with a new thread.
* Exclude certain files from docker builds
* Move config/environments/production.rb to original version
* Add more notes about assets to README.md
  • Loading branch information
cheeyeo authored and Jay Scott committed Oct 15, 2016
1 parent 9255728 commit 735babd
Show file tree
Hide file tree
Showing 8 changed files with 134 additions and 79 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
@@ -0,0 +1,3 @@
.git
.env
.dockerignore
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -31,3 +31,4 @@ playbook.retry

TODO.md
/public/assets
.env
2 changes: 1 addition & 1 deletion 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'

Expand Down
10 changes: 3 additions & 7 deletions Gemfile.lock
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
78 changes: 55 additions & 23 deletions README.md
Expand Up @@ -9,84 +9,116 @@ 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 for integer array support.

To get started, install the OS-level dependencies:

$ sudo apt-get install gnuplot lame build-essential libssl-dev libcurl4-openssl-dev \
```
$ sudo apt-get install gnuplot lame build-essential libssl-dev libcurl4-openssl-dev \
postgresql postgresql-contrib postgresql-common git-core curl libpq-dev sox
```

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
$ psql
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 start making calls.

## Assets

To get assets to show up, you need to first compile assets in production environment:

```
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 through the terminal:

```
export RAILS_SERVE_STATIC_FILES=true
```
or wrap the above in a `.env` file and run source:

```
source .env
```
16 changes: 7 additions & 9 deletions bin/warvox.rb → bin/warvox
Expand Up @@ -15,7 +15,6 @@
$:.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'
Expand Down Expand Up @@ -73,15 +72,13 @@ def usage
end


trap("SIGINT") { stop() }
trap("SIGINT") { Thread.new{ stop } }

$browser_url = "http://#{opts['ServerHost']}:#{opts['ServerPort']}/"

$stderr.puts ""
$stderr.puts "[*] Starting WarVOX on #{$browser_url}"
$stderr.puts ""


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()
Expand All @@ -96,9 +93,10 @@ def usage

@webserver_pid = $$

WarVOX::Log.info("Web Server has PID #{@manager_pid}")
WarVOX::Log.info("Web Server has PID #{@webserver_pid}")

while(ARGV.length > 0); ARGV.shift; end
args.each {|arg| ARGV.push(arg) }

load(voxserv)
# need to pass config opts above into the system command below
system "bin/rails", *args
4 changes: 2 additions & 2 deletions bin/worker_manager.rb
Expand Up @@ -161,8 +161,8 @@ def schedule_submitted_jobs
# 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(0x100000000))
@max_jobs = 3
Expand Down
99 changes: 62 additions & 37 deletions config/environments/production.rb
@@ -1,56 +1,81 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.

# 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 config/initializers/assets.rb

config.action_mailer.perform_caching = false
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# 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 use secure cookies.
# 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 environment)
# 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 raise delivery errors.
# 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-name')

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 code,
# 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

0 comments on commit 735babd

Please sign in to comment.