This commit is contained in:
Seth Call 2020-03-25 07:35:28 -05:00
parent fbc472b054
commit ff21cc8746
6 changed files with 6 additions and 115 deletions

View File

@ -7,6 +7,6 @@ CREATE EXTENSION IF NOT EXISTS fuzzystrmatch WITH SCHEMA public;
CREATE EXTENSION IF NOT EXISTS postgis WITH SCHEMA public;
CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder WITH SCHEMA tiger;
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
CREATE EXTENSION IF NOT EXISTS postgis_topology WITH SCHEMA topology;
--CREATE EXTENSION IF NOT EXISTS postgis_topology WITH SCHEMA topology;
set search_path to 'public';

View File

@ -76,7 +76,7 @@ group :test do
gem 'timecop'
gem 'rspec-prof'
gem 'time_difference'
gem 'byebug'
# gem 'byebug'
gem 'stripe-ruby-mock'
end

View File

@ -74,7 +74,6 @@ GEM
bcrypt (3.1.11)
bcrypt-ruby (3.0.1)
builder (3.2.2)
byebug (9.0.5)
carrierwave (0.9.0)
activemodel (>= 3.2.0)
activesupport (>= 3.2.0)
@ -449,7 +448,6 @@ DEPENDENCIES
aws-sdk (~> 1)
bcrypt-ruby (= 3.0.1)
builder
byebug
carrierwave (= 0.9.0)
database_cleaner (= 1.4.1)
devise (= 3.3.0)
@ -501,4 +499,4 @@ DEPENDENCIES
zip-codes
BUNDLED WITH
1.13.7
1.17.1

View File

@ -1,97 +0,0 @@
# Ensure the cron is using the proper version of ruby, and simply run this with:
# ruby mix_cron.rb
#
require 'faraday'
require 'json'
require 'tempfile'
MIXER_EXECUTABLE = "/usr/local/bin/audiomixerapp"
S3CMD = "s3cmd"
# FIXME: This should probably come from an environments file or something
BASE_URL = "http://www.jamkazam.com"
# This must be present on requests from the cron to prevent hackers from
# hitting these routes.
CRON_TOKEN = "2kkl39sjjf3ijdsflje2923j"
AUDIOMIXER_LOG_FILE = "/var/log/audiomixer"
MIX_CRON_WATCH_FILE = "/var/run/mix_cron"
# Don't do anything if the cron is arleady running. There's a theoretical race
# condition here, but it should never actually be a problem because the cron should
# only run every minute or two.
if File.exist?(MIX_CRON_WATCH_FILE)
psret = `ps axuw | grep mix_cron.rb | grep ruby`
unless psret.empty?
puts "Cron still running"
exit
end
end
`touch #{MIX_CRON_WATCH_FILE}`
# Get the next manifest to mix
response = Faraday.get "#{BASE_URL}/mixes/next", :token => CRON_TOKEN
if response.status > 299
puts "Error response getting next mix: #{response.status}, #{response.body}"
do_exit
end
# This just means no mixes available.
if response.status == 204
do_exit
end
if response.status != 200
puts "Unexpected response received: #{response.status}, #{response.body}"
do_exit
end
json = JSON.parse(response.body)
# This needs to download all the vorbis files, mix and then upload
# the finished one, and tell the server about that.
json['manifest']['files'].map! do |file|
file['filename'] = Dir::Tmpname.make_tmpname ['/tmp/', '.ogg'], nil
file_response = Faraday.get file.url
if file_response.status != 200
puts "Error downloading url: #{file.url}"
do_exit
end
File.open(file['filename'], 'wb') { |fp| fp.write(file_response.body) }
end
output_filename = "/tmp/mixout-#{json['id']}.ogg"
IO.popen("#{MIXER_EXECUTABLE} #{output_filename} vorbis >>& #{AUDIOMIXER_LOG_FILE}", "w") do |f|
f.puts JSON.generate(json)
f.close
end
# First maybe make sure the length is reasonable or something? I bet sox can check that (duration i mean).
# FIXME?: Need to check that the put succeeded before carrying on. Probably can use the exit code or some such.
# Or maybe just do an ls to sanity check it.
`#{S3CMD} -P put #{output_filename} #{json['destination']}`
finish_response = Faraday.put "#{BASE_URL}/mixes/finish", :token => CRON_TOKEN, :id => json['id']
if finish_response.status != 204
puts "Error calling finish on server for mix_id #{json['id']}: #{finish_response.status}, #{finish_response.body}"
do_exit
end
puts "Mix complete and uploaded to: #{json['destination']}"
do_exit
def do_exit
`rm -f #{MIX_CRON_WATCH_FILE}`
end

View File

@ -158,7 +158,7 @@ group :development, :test do
gem 'byebug'
end
group :unix do
gem 'therubyracer' #, '0.11.0beta8'
# gem 'therubyracer' #, '0.11.0beta8'
end
# Gems used only for assets and not required
@ -177,7 +177,7 @@ group :test, :cucumber do
# # necessary on platforms such as arch linux, where pacman -S qt5-webkit is your easiet option
# gem "capybara-webkit", :git => 'git://github.com/thoughtbot/capybara-webkit.git'
#else
gem "capybara-webkit"
# gem "capybara-webkit"
#end
gem 'capybara-screenshot' #, '0.3.22' # 1.0.0 broke compat with rspec. maybe we need newer rspec
gem 'selenium-webdriver'

View File

@ -111,9 +111,6 @@ GEM
capybara-screenshot (1.0.14)
capybara (>= 1.0, < 3)
launchy
capybara-webkit (1.14.0)
capybara (>= 2.3.0, < 2.14.0)
json
carmen (1.0.2)
activesupport (>= 3.0.0)
carrierwave (0.11.2)
@ -409,7 +406,6 @@ GEM
language_list (1.2.1)
launchy (2.1.1)
addressable (~> 2.3)
libv8 (3.16.14.19)
little-plugger (1.1.4)
logging (1.7.2)
little-plugger (>= 1.1.3)
@ -583,7 +579,6 @@ GEM
redis (3.3.3)
redis-namespace (1.5.3)
redis (~> 3.0, >= 3.0.4)
ref (2.0.0)
responders (2.4.0)
actionpack (>= 4.2.0, < 5.3)
railties (>= 4.2.0, < 5.3)
@ -704,9 +699,6 @@ GEM
temple (0.8.0)
test-unit (3.2.4)
power_assert
therubyracer (0.12.3)
libv8 (~> 3.16.14.15)
ref
thor (0.19.4)
thread_safe (0.3.6)
tilt (2.0.7)
@ -764,7 +756,6 @@ DEPENDENCIES
byebug
capybara
capybara-screenshot
capybara-webkit
carmen
carrierwave (= 0.11.2)
carrierwave_direct
@ -863,7 +854,6 @@ DEPENDENCIES
sprockets-rails (= 2.3.2)
stripe
test-unit
therubyracer
timecop
twitter
uglifier
@ -874,4 +864,4 @@ DEPENDENCIES
zip-codes
BUNDLED WITH
1.13.7
1.17.1