diff --git a/.env.example b/.env.example deleted file mode 100644 index 8bddeb2..0000000 --- a/.env.example +++ /dev/null @@ -1,2 +0,0 @@ -DOMAIN_NAME: -SECRET_KEY_BASE: diff --git a/app/assets/javascripts/v_libras/videos/index.js b/app/assets/javascripts/v_libras/videos/index.js deleted file mode 100644 index 1df4510..0000000 --- a/app/assets/javascripts/v_libras/videos/index.js +++ /dev/null @@ -1,16 +0,0 @@ -$(function() { - $("a.badge").tooltip(); - - // connect to server like normal - // FIXME: how to get the right address - var dispatcher = new WebSocketRails('localhost:3000/websocket'); - - // subscribe to the channel - var channel = dispatcher.subscribe('requests_update'); - - // bind to a channel event - channel.bind('update', function(data) { - alert("Um vídeo que estava em processamento está disponível. Sua página será atualizada automaticamente.") - location.reload(); - }); -}); \ No newline at end of file diff --git a/app/assets/javascripts/v_libras/videos/index.js.erb b/app/assets/javascripts/v_libras/videos/index.js.erb new file mode 100644 index 0000000..c6d4a2c --- /dev/null +++ b/app/assets/javascripts/v_libras/videos/index.js.erb @@ -0,0 +1,14 @@ +$(function() { + $("a.badge").tooltip(); + + var dispatcher = new WebSocketRails('<%= ENV['DOMAIN_NAME'] %>/websocket'); + + // subscribe to the channel + var channel = dispatcher.subscribe('requests_update'); + + // bind to a channel event + channel.bind('update', function(data) { + alert("Um vídeo que estava em processamento está disponível. Sua página será atualizada automaticamente.") + location.reload(); + }); +}); \ No newline at end of file diff --git a/config/application.rb b/config/application.rb index 1f5ed78..8798f61 100644 --- a/config/application.rb +++ b/config/application.rb @@ -21,6 +21,8 @@ module Vlibras # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] - config.i18n.default_locale = 'pt-BR' + config.i18n.enforce_available_locales = false + config.i18n.available_locales = ["pt-BR"] + config.i18n.default_locale = :'pt-BR' end end diff --git a/config/database.yml.example b/config/database.yml.example deleted file mode 100644 index c1c60d0..0000000 --- a/config/database.yml.example +++ /dev/null @@ -1,19 +0,0 @@ -# SQLite version 3.x -# gem install sqlite3 -# -# Ensure the SQLite 3 gem is defined in your Gemfile -# gem 'sqlite3' -development: - adapter: sqlite3 - database: db/development.sqlite3 - pool: 5 - timeout: 5000 - -# Warning: The database defined as "test" will be erased and -# re-generated from your development database when you run "rake". -# Do not set this db to the same as development or production. -test: - adapter: sqlite3 - database: db/test.sqlite3 - pool: 5 - timeout: 5000 \ No newline at end of file diff --git a/config/deploy.rb b/config/deploy.rb index 96bed89..064172d 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -25,7 +25,7 @@ set :use_sudo, false # set :log_level, :debug # Default value for :pty is false -# set :pty, true +set :pty, true # Default value for :linked_files is [] set :linked_files, %w{config/database.yml .env} @@ -40,12 +40,10 @@ set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public set :keep_releases, 3 namespace :deploy do - desc 'Restart application' task :restart do on roles(:app), in: :sequence, wait: 5 do - # Your restart mechanism here, for example: - execute :touch, release_path.join('tmp/restart.txt') + run "rvmsudo restart vlibras-web2" end end @@ -54,9 +52,10 @@ namespace :deploy do after :restart, :clear_cache do on roles(:web), in: :groups, limit: 3, wait: 10 do # Here we can do anything such as: - within release_path do - execute :rake, 'cache:clear' - end + #within release_path do + # execute :rake, 'assets:clean -e production' + # execute :rake, 'tmp:clear -e production' + #end end end diff --git a/config/examples/.env.example b/config/examples/.env.example new file mode 100644 index 0000000..ed17866 --- /dev/null +++ b/config/examples/.env.example @@ -0,0 +1,7 @@ +SECRET_KEY_BASE: 59f3123227a531056f058c06f4c0ac40c072d8b23855c29ee6f4c8cf75176f0ef51cb18e2f41b52246fba93 +DOMAIN_NAME: # for api callback + +VLIBRAS_API: + +# gmail password +# api address... \ No newline at end of file diff --git a/config/examples/Procfile.deployment b/config/examples/Procfile.deployment new file mode 100644 index 0000000..5ff0fce --- /dev/null +++ b/config/examples/Procfile.deployment @@ -0,0 +1,2 @@ +web: /home/deploy/.rvm/wrappers/vlibras-web2/bundle exec thin start -C /srv/vlibras-web2/shared/thin.yml -p $PORT +worker: /home/deploy/.rvm/wrappers/vlibras-web2/bundle exec rake jobs:work RAILS_ENV=production diff --git a/config/examples/database.yml b/config/examples/database.yml new file mode 100644 index 0000000..c1c60d0 --- /dev/null +++ b/config/examples/database.yml @@ -0,0 +1,19 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +development: + adapter: sqlite3 + database: db/development.sqlite3 + pool: 5 + timeout: 5000 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + adapter: sqlite3 + database: db/test.sqlite3 + pool: 5 + timeout: 5000 \ No newline at end of file diff --git a/config/examples/thin.yml b/config/examples/thin.yml new file mode 100644 index 0000000..a74c5f2 --- /dev/null +++ b/config/examples/thin.yml @@ -0,0 +1,16 @@ +--- +chdir: "/srv/vlibras-web2/current" +environment: production +address: 0.0.0.0 +timeout: 30 +log: "/srv/vlibras-web2/shared/log/thin.log" +pid: "/tmp/pids/thin.pid" +max_conns: 1024 +max_persistent_conns: 100 +require: [] +wait: 30 +threadpool_size: 20 + +# port: 3000 +# servers: 3 +# daemonize: true \ No newline at end of file diff --git a/config/initializers/check_env_vars.rb b/config/initializers/check_env_vars.rb new file mode 100644 index 0000000..5dd7168 --- /dev/null +++ b/config/initializers/check_env_vars.rb @@ -0,0 +1,7 @@ +if ENV['DOMAIN_NAME'].nil? || ENV['DOMAIN_NAME'].empty? + raise 'DOMAIN_NAME must be set in .env (used for callback url)' +end + +if ENV['VLIBRAS_API_URL'].nil? || ENV['VLIBRAS_API_URL'].empty? + raise 'VLIBRAS_API_URL must be set in .env' +end diff --git a/config/initializers/websocket_rails.rb b/config/initializers/websocket_rails.rb index 6029adf..cdef292 100644 --- a/config/initializers/websocket_rails.rb +++ b/config/initializers/websocket_rails.rb @@ -20,7 +20,7 @@ WebsocketRails.setup do |config| # Change to true to enable channel synchronization between # multiple server instances. # * Requires Redis. - config.synchronize = false + config.synchronize = true # Prevent Thin from daemonizing (default is true) # config.daemonize = false diff --git a/lib/api_client.rb b/lib/api_client.rb index d378e78..9b28239 100644 --- a/lib/api_client.rb +++ b/lib/api_client.rb @@ -1,5 +1,5 @@ class ApiClient - API_URL = 'http://150.165.204.30:5000/api' + API_URL = ENV['VLIBRAS_API_URL'] def self.check_status begin diff --git a/lib/api_client/client.rb b/lib/api_client/client.rb index e7a5397..dc0c5ba 100644 --- a/lib/api_client/client.rb +++ b/lib/api_client/client.rb @@ -34,7 +34,7 @@ module ApiClient::Client def self.process_params(request, files) options = { query: request.params.clone } options[:query].merge!(:servico => request.service_type) - options[:query].merge!(:callback => "http://150.165.205.192:3000/v_libras/requests/callback?request_id=#{request.id}") + options[:query].merge!(:callback => "http://#{ENV['DOMAIN_NAME']}/v_libras/requests/callback?request_id=#{request.id}") options[:query].merge!(:video => files[:video].file.to_file) -- libgit2 0.21.2