From aa420b6bdbad11a083d2cb0ad887fb254cb77ef5 Mon Sep 17 00:00:00 2001 From: Aaron Manaloto Date: Thu, 28 Jul 2022 17:27:02 +0800 Subject: [PATCH] Test webrick gem --- .do/deploy.template.yaml | 3 +-- .gitignore | 1 - Procfile | 1 + app.json | 2 +- config/database.yml | 36 ++++++++++++++++++++++++++++++++++++ config/unicorn.rb | 22 ++++++++++++++++++++++ 6 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 Procfile create mode 100644 config/database.yml create mode 100644 config/unicorn.rb diff --git a/.do/deploy.template.yaml b/.do/deploy.template.yaml index aca304932..9d1497b21 100644 --- a/.do/deploy.template.yaml +++ b/.do/deploy.template.yaml @@ -10,7 +10,6 @@ spec: value: enabled scope: RUN_TIME git: - branch: develop + branch: fix-heroku-1-click repo_clone_url: https://github.com/dradis/dradis-ce.git name: web - run_command: ./bin/setup diff --git a/.gitignore b/.gitignore index b618c7c5f..e3229c284 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,6 @@ # Rails stuff /db/*.sqlite3 /db/*.sqlite3-* -/config/database.yml /config/secrets.yml /config/smtp.yml /log/* diff --git a/Procfile b/Procfile new file mode 100644 index 000000000..9c8237414 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb diff --git a/app.json b/app.json index ed08ea592..3455a4d17 100644 --- a/app.json +++ b/app.json @@ -20,7 +20,7 @@ "keywords": ["infosec", "pentest", "osint"], "logo": "https://github.com/dradis/dradis-ce/raw/deploy-to-heroku/app/assets/images/logo_small.png", "name": "Dradis Framework - Community Edition", - "repository": "https://github.com/dradis/dradis-ce/tree/deploy-to-heroku", + "repository": "https://github.com/dradis/dradis-ce/tree/develop", "scripts": { "postdeploy": "bin/heroku" }, diff --git a/config/database.yml b/config/database.yml new file mode 100644 index 000000000..196f708f8 --- /dev/null +++ b/config/database.yml @@ -0,0 +1,36 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# MySQL version - make sure the mysql2 gem is included in your Gemfile +# If you uncomment this development: block, comment the previous one. +# development: +# adapter: mysql2 +# encoding: utf8 +# collation: utf8_bin +# database: dradis_dev +# username: root +# socket: /tmp/mysql.sock + + +# 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: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/config/unicorn.rb b/config/unicorn.rb new file mode 100644 index 000000000..f6e59b8f2 --- /dev/null +++ b/config/unicorn.rb @@ -0,0 +1,22 @@ +worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3) +timeout 15 +preload_app true + +before_fork do |server, worker| + Signal.trap 'TERM' do + puts 'Unicorn master intercepting TERM and sending myself QUIT instead' + Process.kill 'QUIT', Process.pid + end + + defined?(ActiveRecord::Base) and + ActiveRecord::Base.connection.disconnect! +end + +after_fork do |server, worker| + Signal.trap 'TERM' do + puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT' + end + + defined?(ActiveRecord::Base) and + ActiveRecord::Base.establish_connection +end