mirror of
				https://github.com/lingble/chatwoot.git
				synced 2025-10-30 18:47:51 +00:00 
			
		
		
		
	 7cbf1857e4
			
		
	
	7cbf1857e4
	
	
	
		
			
			By default, Rails does not set a timeout on database statements. For example, this will run for a full day, even if your ruby process goes away. But it's configurable in the database.yml with the statement_timeout variable.
Hence we are enforcing a 14s timeout by default. Migration commands inside chatwoot will run with a 10 minutes timeout. For specific cases like migrations, we can override this timeout using the environment variable POSTGRES_STATEMENT_TIMEOUT while starting a new rails console.
Test the timeouts from the rails console using.
```
ActiveRecord::Base.connection.execute("SELECT pg_sleep(15);")
```
ref: https://github.com/ankane/the-ultimate-guide-to-ruby-timeouts#postgresql
ref: https://til.hashrocket.com/posts/b44baf657d-railspg-statement-timeout-
		
	
		
			
				
	
	
		
			32 lines
		
	
	
		
			851 B
		
	
	
	
		
			Ruby
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
		
			851 B
		
	
	
	
		
			Ruby
		
	
	
		
			Executable File
		
	
	
	
	
| #!/usr/bin/env ruby
 | |
| require 'fileutils'
 | |
| include FileUtils
 | |
| 
 | |
| # path to your application root.
 | |
| APP_ROOT = File.expand_path('..', __dir__)
 | |
| 
 | |
| def system!(*args)
 | |
|   system(*args) || abort("\n== Command #{args} failed ==")
 | |
| end
 | |
| 
 | |
| chdir APP_ROOT do
 | |
|   # This script is a way to update your development environment automatically.
 | |
|   # Add necessary update steps to this file.
 | |
| 
 | |
|   puts '== Installing dependencies =='
 | |
|   system! 'gem install bundler --conservative'
 | |
|   system('bundle check') || system!('bundle install')
 | |
| 
 | |
|   # Install JavaScript dependencies if using Yarn
 | |
|   # system('bin/yarn')
 | |
| 
 | |
|   puts "\n== Updating database =="
 | |
|   system! 'POSTGRES_STATEMENT_TIMEOUT=600s bin/rails db:migrate'
 | |
| 
 | |
|   puts "\n== Removing old logs and tempfiles =="
 | |
|   system! 'bin/rails log:clear tmp:clear'
 | |
| 
 | |
|   puts "\n== Restarting application server =="
 | |
|   system! 'bin/rails restart'
 | |
| end
 |