Commit 9002215d054076a966c44cd602e7f18bd0d06daa

Authored by Fernando Brito
1 parent 05c6a186
Exists in master and in 2 other branches v2, wikilibras

Changes to make it easier to deploy

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