diff --git a/Dockerfile b/Dockerfile index b3bb4b8..7ed024c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,3 +15,4 @@ COPY . /myapp COPY ./build/puma.rb /myapp/config/puma.rb EXPOSE 8080 +ENTRYPOINT ["./docker-entrypoint.sh"] diff --git a/app/lib/unifi.rb b/app/lib/unifi.rb index b22b27f..d4b4bbb 100644 --- a/app/lib/unifi.rb +++ b/app/lib/unifi.rb @@ -94,7 +94,8 @@ def login_unifi_client(client_mac, minutes=60, logout=false) conn = Faraday.new( url: host + "/api/s/#{metadata['unifi_site_name']}/cmd/stamgr", - ssl: { verify: false } + ssl: { verify: false }, + request: { timeout: 2, open_timeout: 2 } ) cmd = logout ? 'unauthorize-guest' : 'authorize-guest' @@ -346,7 +347,8 @@ def create_guest_settings def get_unifi(path, opts={}, cookies=nil) conn = Faraday.new( url: host + "/api#{path}", - ssl: { verify: false } + ssl: { verify: false }, + request: { timeout: 2, open_timeout: 2 } ) response = conn.get do |req| req.body = opts.to_json if opts.present? @@ -370,7 +372,8 @@ def get_unifi(path, opts={}, cookies=nil) def post_unifi(path, opts={}, cookies=nil) conn = Faraday.new( url: host + "/api#{path}", - ssl: { verify: false } + ssl: { verify: false }, + request: { timeout: 2, open_timeout: 2 } ) resp = conn.post do |req| req.body = opts.to_json if opts.present? diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index ce9bd7c..326e01a 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -4,7 +4,7 @@ class UserMailer < ApplicationMailer def new_code @user = params[:user] - @url = "#{ENV['MIMO_DASHBOARD_URL']}/wizard/start?code=#{generate_code}" + @url = "#{ENV['MIMO_API_URL']}/wizard/start?code=#{generate_code}" mail(to: @user.email, subject: 'New setup code!') end diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 0000000..610a3a8 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,12 @@ +#!/bin/sh +set -e + +if [ -f tmp/pids/server.pid ]; then + rm tmp/pids/server.pid +fi + +bundle exec rake db:migrate 2>/dev/null || bundle exec rake db:setup +# bundle exec rake assets:precompile +# bundle exec rake production:bootstrap + +exec bundle exec "$@"