From ee225ea5ac8771e22f43ede8d17af37ad6cf813d Mon Sep 17 00:00:00 2001 From: Tom Naessens Date: Sat, 8 Jun 2024 18:50:20 +0200 Subject: [PATCH] Dockerize, Postgresize, Redisize, and Sidekiqize Tap --- .github/workflows/ruby.yml | 33 ++++++----- .ruby-version | 2 +- .tool-versions | 2 +- Gemfile | 23 +++----- Gemfile.lock | 49 +++++++---------- Procfile.dev | 3 + README.md | 55 +++++-------------- app/controllers/orders_controller.rb | 2 +- app/jobs/tab_api_job.rb | 10 ++-- app/models/order.rb | 6 +- bin/delayed_job | 5 -- bin/dev | 10 ++++ config/application.rb | 4 +- config/database.yml | 25 ++++----- config/deploy.rb | 23 +++----- config/deploy/staging.rb | 7 --- config/environments/development.rb | 1 - config/initializers/delayed_job_config.rb | 2 - config/initializers/sidekiq.rb | 3 + config/routes.rb | 6 ++ config/secrets.yml | 11 ++-- config/sidekiq.yml | 5 ++ ...20240608163258_remove_delayed_job_table.rb | 5 ++ docker-compose.prod.yml | 52 ++++++++++++++++++ docker-compose.yml | 54 +++++++++++------- lib/capistrano/tasks/delayed_job.cap | 44 --------------- lib/capistrano/tasks/logs.cap | 8 --- 27 files changed, 207 insertions(+), 243 deletions(-) create mode 100644 Procfile.dev delete mode 100755 bin/delayed_job create mode 100755 bin/dev delete mode 100644 config/deploy/staging.rb delete mode 100644 config/initializers/delayed_job_config.rb create mode 100644 config/initializers/sidekiq.rb create mode 100644 config/sidekiq.yml create mode 100644 db/migrate/20240608163258_remove_delayed_job_table.rb create mode 100644 docker-compose.prod.yml delete mode 100644 lib/capistrano/tasks/delayed_job.cap delete mode 100644 lib/capistrano/tasks/logs.cap diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 8cecc79a..375401c0 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -7,24 +7,25 @@ on: jobs: test: runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - bundler-cache: true - - - run: RAILS_ENV=test bundle exec rake db:create - - run: RAILS_ENV=test bundle exec rake db:schema:load - - run: bundle exec rake - env: - COVERALLS_REPO_TOKEN : ${{ secrets.COVERALLS_REPO_TOKEN }} + - uses: actions/checkout@v4 + + - name: Build the stack + run: docker-compose up -d db-test + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + + - run: RAILS_ENV=test bundle exec rake db:create + - run: RAILS_ENV=test bundle exec rake db:schema:load + - run: bundle exec rake + lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Ruby uses: ruby/setup-ruby@v1 @@ -32,7 +33,5 @@ jobs: bundler-cache: true - name: Lint with rubocop - env: - RAILS_ENV: "test" run: | - bundle exec rubocop -c .rubocop.yml + bundle exec rubocop -c .rubocop.yml diff --git a/.ruby-version b/.ruby-version index bea438e9..47725433 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.3.1 +3.3.2 diff --git a/.tool-versions b/.tool-versions index f76d2631..da68b39d 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,3 +1,3 @@ -ruby 3.3.1 +ruby 3.3.2 yarn 1.22.19 nodejs 16.15.0 diff --git a/Gemfile b/Gemfile index 7c35d054..e8eb26e0 100644 --- a/Gemfile +++ b/Gemfile @@ -59,11 +59,6 @@ gem "cancancan", "~> 3.3" # Default avatar for users gem "identicon", "0.0.5" -# Run stuff in the background -gem "daemons", "~> 1.4" -gem "delayed_job", "~> 4.1" -gem "delayed_job_active_record" - # Needed for deployment somehow gem "bcrypt_pbkdf" gem "ed25519" @@ -81,10 +76,11 @@ gem "sentry-rails" gem "sentry-ruby" gem "stackprof" -# Production dependencies -group :production do - gem "mysql2", "~> 0.5.3" -end +# Run stuff in background +gem "sidekiq", "~> 7.0" + +# Use PostgreSQL as the database for Active Record +gem "pg" # Test dependencies group :test do @@ -94,9 +90,6 @@ end # Development dependencies group :development do - # Use sqlite3 as the database for Active Record - gem "sqlite3", "~> 1.4" - # Annotates Rails/ActiveRecord Models, routes, fixtures, and others based on the database schema. gem "annotate", "~> 3.1" @@ -104,10 +97,8 @@ group :development do gem "spring", "~> 3.0" # Deployment - gem "capistrano" - gem "capistrano-asdf" - gem "capistrano-passenger" - gem "capistrano-rails" + gem "capistrano", "~> 3.17" + gem "capistrano-docker", github: "TomNaessens/capistrano-docker" # Linting gem "rubocop", "~> 1.30" diff --git a/Gemfile.lock b/Gemfile.lock index bbc54ce2..04ef7051 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,10 @@ +GIT + remote: https://github.com/TomNaessens/capistrano-docker.git + revision: 490311def501a5d32a24e52d6952d355a85b6cfe + specs: + capistrano-docker (0.4.0) + capistrano (>= 3.3) + GEM remote: https://rubygems.org/ specs: @@ -84,30 +91,15 @@ GEM i18n rake (>= 10.0.0) sshkit (>= 1.9.0) - capistrano-asdf (1.1.1) - capistrano (~> 3.0) - sshkit (~> 1.2) - capistrano-bundler (2.0.1) - capistrano (~> 3.1) - capistrano-passenger (0.2.1) - capistrano (~> 3.0) - capistrano-rails (1.6.2) - capistrano (~> 3.1) - capistrano-bundler (>= 1.1, < 3) chartkick (4.1.3) chunky_png (1.4.0) climate_control (0.2.0) concurrent-ruby (1.2.3) + connection_pool (2.4.1) crack (0.4.5) rexml crass (1.0.6) - daemons (1.4.1) date (3.3.4) - delayed_job (4.1.10) - activesupport (>= 3.0, < 8.0) - delayed_job_active_record (4.1.7) - activerecord (>= 3.0, < 8.0) - delayed_job (>= 3.0, < 5) devise (4.8.1) bcrypt (~> 3.0) orm_adapter (~> 0.1) @@ -176,7 +168,6 @@ GEM multi_json (1.15.0) multi_xml (0.6.0) mutex_m (0.2.0) - mysql2 (0.5.4) net-imap (0.4.11) date net-protocol @@ -221,6 +212,7 @@ GEM parser (3.3.1.0) ast (~> 2.4.1) racc + pg (1.5.6) psych (5.1.2) stringio public_suffix (4.0.7) @@ -273,6 +265,8 @@ GEM ffi (~> 1.0) rdoc (6.7.0) psych (>= 4.0.0) + redis-client (0.22.2) + connection_pool regexp_parser (2.9.2) responders (3.0.1) actionpack (>= 5.0) @@ -334,6 +328,11 @@ GEM sentry-ruby (5.17.3) bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) + sidekiq (7.2.4) + concurrent-ruby (< 2) + connection_pool (>= 2.3.0) + rack (>= 2.2.4) + redis-client (>= 0.19.0) spring (3.1.1) sprockets (4.0.3) concurrent-ruby (~> 1.0) @@ -342,9 +341,6 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) - sqlite3 (1.7.3-arm64-darwin) - sqlite3 (1.7.3-x86_64-darwin) - sqlite3 (1.7.3-x86_64-linux) sshkit (1.22.2) base64 mutex_m @@ -395,14 +391,9 @@ DEPENDENCIES bulma-rails (~> 0.9.1) byebug cancancan (~> 3.3) - capistrano - capistrano-asdf - capistrano-passenger - capistrano-rails + capistrano (~> 3.17) + capistrano-docker! chartkick (~> 4.0) - daemons (~> 1.4) - delayed_job (~> 4.1) - delayed_job_active_record devise (~> 4.8) dotenv-rails ed25519 @@ -415,12 +406,12 @@ DEPENDENCIES identicon (= 0.0.5) kt-paperclip (~> 7.0) listen (~> 3.7) - mysql2 (~> 0.5.3) net-imap net-pop net-smtp omniauth-rails_csrf_protection omniauth-zeuswpi + pg puma (~> 5.5.0) rails (~> 6.1) rails-controller-testing (~> 1.0) @@ -432,8 +423,8 @@ DEPENDENCIES sdoc (~> 2.2) sentry-rails sentry-ruby + sidekiq (~> 7.0) spring (~> 3.0) - sqlite3 (~> 1.4) stackprof tqdm (~> 0.3.0) tzinfo-data diff --git a/Procfile.dev b/Procfile.dev new file mode 100644 index 00000000..ebf1cbff --- /dev/null +++ b/Procfile.dev @@ -0,0 +1,3 @@ +web: PORT=3000 rails s +sidekiq: bundle exec sidekiq +db: docker-compose up diff --git a/README.md b/README.md index e685f5b1..ff757e76 100644 --- a/README.md +++ b/README.md @@ -7,47 +7,17 @@ To provide a consistent experience on every system, docker and docker-compose is used during development and production. -### Using Docker and Make *(recommended)* +1. Install the prerequisites: ruby `$(cat .ruby-version)`, preferably using [asdf](https://asdf-vm.com/), and some system libraries depending on your OS (e.g. imagemagick) +2. Install the ruby dependencies: `bin/bundle` +3. Start up the database, sidekiq and rails server by running `bin/dev` +4. Set up some database data using `rails db:setup` +5. Browse to http://localhost:3000 -#### Linux/Unix +In case you want to start the webserver in your IDE, just run `docker-compose up -d` and start Sidekiq manually (`bundle exec sidekiq`) -1. Install [Docker](https://docs.docker.com/get-docker/) and [Docker Compose](https://docs.docker.com/compose/install/) -2. Start the development server - ```sh - make dev - ``` +## Deploying - > This will start a development server on http://localhost:3000 -3. Seed the database. - ```sh - make dev-seed - ``` - - > The development setup uses an SQLite 3 database, which can be found under `/db/development.sqlite3` - -#### Windows - -1. Install [WSL (Windows Subsystem for Linux)](https://docs.microsoft.com/en-us/windows/wsl/install-win10) -2. Follow the instructions for Linux/Unix above - -### Directly on your system - -1. Install [asdf](http://asdf-vm.com/guide/getting-started.html#getting-started) -2. Install dependencies: `asdf install` -3. Install gems: `bundle install` -4. Migrate the db using `bundle exec rails db:migrate` -5. Seed the db using `bundle exec rails db:seed` -6. Start Tap by running `bundle exec rails s` - -## Production - -You can generate a production docker image using: - -```sh -make build -``` - -> The image will be tagged under `tap:latest` +_Locally_, run `bundle exec cap production deploy` ## FAQ @@ -73,9 +43,12 @@ make build
There are no transactions going from Tap to Tab - The delay job may not be running. You can start it using: + Sidekiq might not be running. Check the dashboard on https://tap.zeus.gent/sidekiq. + + You can start by redeploying the application, or by turning the deployment on the server off & on (inside the `/home/tap/production/current` directory): - ```sh - sudo -u tap RAILS_ENV=production /home/tap/production/current/bin/delayed_job start + ```bash + podman-compose -f docker-compose.prod.yml -p tap down + podman-compose -f docker-compose.prod.yml -p tap up -d ```
diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb index 500fe383..14e4c7c8 100644 --- a/app/controllers/orders_controller.rb +++ b/app/controllers/orders_controller.rb @@ -152,7 +152,7 @@ def create # Create an order # POST(method: DELETE) /users/{username}/orders/{id} def destroy - @order.destroy + @order.destroy! respond_to do |format| format.json { head :no_content } format.html do diff --git a/app/jobs/tab_api_job.rb b/app/jobs/tab_api_job.rb index bdfca41f..5de519ea 100644 --- a/app/jobs/tab_api_job.rb +++ b/app/jobs/tab_api_job.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -TabApiJob = Struct.new(:order_id) do - def perform(*_args) +class TabApiJob < ApplicationJob + def perform(order_id) order = Order.find_by(id: order_id) return unless order && !order.transaction_id @@ -22,13 +22,11 @@ def perform(*_args) order.update(transaction_id: JSON.parse(result.body)["id"].to_i) end + private + def headers { "Authorization" => "Token token=#{Rails.application.secrets.tab_api_key}" } end - - def error(_job, exception) - Airbrake.notify(exception) - end end diff --git a/app/models/order.rb b/app/models/order.rb index daac94fe..c544c8ed 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -61,11 +61,7 @@ def calculate_price def create_api_job return if Rails.env.test? - priority = 0 - run_at = Rails.application.config.call_api_after.from_now - job = TabApiJob.new(id) - - Delayed::Job.enqueue job, priority: priority, run_at: run_at + TabApiJob.set(wait: Rails.application.config.call_api_after).perform_later(id) end def product_presence diff --git a/bin/delayed_job b/bin/delayed_job deleted file mode 100755 index edf19598..00000000 --- a/bin/delayed_job +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env ruby - -require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment')) -require 'delayed/command' -Delayed::Command.new(ARGV).daemonize diff --git a/bin/dev b/bin/dev new file mode 100755 index 00000000..72ff9603 --- /dev/null +++ b/bin/dev @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +docker-compose up -d + +if ! command -v foreman &> /dev/null +then + echo "Installing foreman…" + gem install foreman +fi + +foreman start -f Procfile.dev "$@" diff --git a/config/application.rb b/config/application.rb index 924e3f67..7f140a02 100644 --- a/config/application.rb +++ b/config/application.rb @@ -15,8 +15,8 @@ class Application < Rails::Application # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. config.time_zone = 'Brussels' - # Setup delayed jobs - config.active_job.queue_adapter = :delayed_job + # Setup Sidekiq + config.active_job.queue_adapter = :sidekiq config.call_api_after = 5.minutes config.frecency_num_orders = 25 diff --git a/config/database.yml b/config/database.yml index 1c1a37ca..d2a0dc7a 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,25 +1,20 @@ -# SQLite version 3.x -# gem install sqlite3 -# -# Ensure the SQLite 3 gem is defined in your Gemfile -# gem 'sqlite3' -# default: &default - adapter: sqlite3 - pool: 5 - timeout: 5000 + adapter: postgresql + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + host: 127.0.0.1 + username: postgres + password: password + encoding: utf8 + port: 5432 development: <<: *default - database: db/development.sqlite3 + database: tap -# 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 + database: tap-test + port: 5433 production: <<: *default - database: db/production.sqlite3 diff --git a/config/deploy.rb b/config/deploy.rb index 4fbe44fb..83c20dcd 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -26,7 +26,7 @@ # set :pty, true # Default value for :linked_files is [] -set :linked_files, %w{config/database.yml config/secrets.yml .env} +set :linked_files, [] # Default value for linked_dirs is [] set :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system} @@ -37,16 +37,11 @@ # Default value for keep_releases is 5 # set :keep_releases, 5 -namespace :passenger do - desc "Restart Application" - task :restart do - on roles(:app) do - with rails_env: fetch(:rails_env) do - execute "touch #{current_path}/tmp/restart.txt" - end - end - invoke 'delayed_job:restart' - end -end - -after :deploy, "passenger:restart" +# capistrano-docker specific +set :docker_command, "podman" +set :docker_copy_data, %w{.env config/database.yml} + +set :docker_compose, true +set :docker_compose_path, "docker-compose.prod.yml" +set :docker_compose_command, "podman-compose" +set :docker_compose_project_name, "tap" diff --git a/config/deploy/staging.rb b/config/deploy/staging.rb deleted file mode 100644 index 86752d05..00000000 --- a/config/deploy/staging.rb +++ /dev/null @@ -1,7 +0,0 @@ -server 'king.ugent.be', user: 'tap', roles: %w{web app db}, ssh_options: { - forward_agent: true, - auth_methods: ['publickey'], - port: 2222 -} - -set :rails_env, 'production' diff --git a/config/environments/development.rb b/config/environments/development.rb index 88611547..51f38058 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -80,5 +80,4 @@ config.api_url = "http://localhost:3001/api/v1/" config.tab_user_url = "http://localhost:3001/" - Delayed::Worker.logger = Rails.logger end diff --git a/config/initializers/delayed_job_config.rb b/config/initializers/delayed_job_config.rb deleted file mode 100644 index 7323b719..00000000 --- a/config/initializers/delayed_job_config.rb +++ /dev/null @@ -1,2 +0,0 @@ -Delayed::Worker.destroy_failed_jobs = false -Delayed::Worker.logger = Logger.new(File.join(Rails.root, 'log', 'delayed_job.log')) diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb new file mode 100644 index 00000000..c28d21a2 --- /dev/null +++ b/config/initializers/sidekiq.rb @@ -0,0 +1,3 @@ +Sidekiq.configure_server do |config| + config.redis = { url: ENV["REDIS_URL"] || "redis://localhost:6379" } +end diff --git a/config/routes.rb b/config/routes.rb index 290483bc..88645478 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,6 +3,12 @@ # This method is responsible to generate all needed routes for devise, based on what modules you have defined in your model. devise_for :users, controllers: { omniauth_callbacks: "callbacks" } + # Sidekiq UI + require 'sidekiq/web' + authenticate :user, -> (user) { user.admin? } do + mount Sidekiq::Web => '/sidekiq' + end + # Authentication # Using "devise" devise_scope :user do diff --git a/config/secrets.yml b/config/secrets.yml index 388228df..6636e459 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -14,20 +14,17 @@ development: secret_key_base: 5d40610321e19e4f71ee2ba8af4f426fe15096c405da3800c6b33bed6779f2d11f55a0edc455974b19a01fd71f6cd508dba980305dbc55ff82521a2d12f891d8 omniauth_client_id: tomtest omniauth_client_secret: blargh - access_token: "token" tab_api_key: "o6UIYc0r0cvsy0Ohaohqsw==" koelkast_token: "token" test: secret_key_base: 961437e28e7d6055ffaad9cf1f8d614354f57f10cb2d7601c9d6ede72a03b9c9535ad9e63507e3eb31252c4895970a63117493408f2e9a46c7a0c4a5a7836b81 - access_token: "token" # Do not keep production secrets in the repository, # instead read values from the environment. production: secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> - omniauth_client_id: "" - omniauth_client_secret: "" - access_token: "" - tab_api_key: "" - koelkast_token: "" + omniauth_client_id: <%= ENV["OMNIAUTH_CLIENT_ID"] %> + omniauth_client_secret: <%= ENV["OMNIAUTH_CLIENT_SECRET"] %> + tab_api_key: <%= ENV["TAB_API_KEY"] %> + koelkast_token: <%= ENV["KOEKAST_TOKEN"] %> diff --git a/config/sidekiq.yml b/config/sidekiq.yml new file mode 100644 index 00000000..b68d2e2d --- /dev/null +++ b/config/sidekiq.yml @@ -0,0 +1,5 @@ +--- +:concurrency: 1 +:queues: + - default + - mailers diff --git a/db/migrate/20240608163258_remove_delayed_job_table.rb b/db/migrate/20240608163258_remove_delayed_job_table.rb new file mode 100644 index 00000000..f8b46e96 --- /dev/null +++ b/db/migrate/20240608163258_remove_delayed_job_table.rb @@ -0,0 +1,5 @@ +class RemoveDelayedJobTable < ActiveRecord::Migration[6.1] + def up + drop_table :delayed_jobs + end +end diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml new file mode 100644 index 00000000..68b67559 --- /dev/null +++ b/docker-compose.prod.yml @@ -0,0 +1,52 @@ +version: '3.3' + +services: + db: + image: postgres:16 + environment: + POSTGRES_DB: tap + POSTGRES_USER: postgres + POSTGRES_PASSWORD: password + volumes: + - tap_data:/var/lib/postgresql/data + ports: + - "5432:5432" + + web: + build: . + depends_on: + - db + ports: + - "3004:3000" + volumes: + - storage:/app/storage + environment: + DATABASE_URL: postgresql://postgres:password@db/tap + RAILS_LOG_TO_STDOUT: 1 + SECRET_AUTH_USERNAME: admin + SECRET_AUTH_PASSWORD: admin-password + RAILS_SERVE_STATIC_FILES: 1 + + sidekiq: + build: . + depends_on: + - db + - redis + volumes: + - storage:/app/storage + environment: + DATABASE_URL: postgresql://postgres:password@db/tap + REDIS_URL: redis://redis:6379 + entrypoint: bundle exec sidekiq + + redis: + image: redis:7-alpine + volumes: + - redis_data:/data + ports: + - "6379:6379" + +volumes: + tap_data: + redis_data: + storage: diff --git a/docker-compose.yml b/docker-compose.yml index fefe7a73..f9d2427e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,25 +1,37 @@ # -# This compose file is meant for development and should not be used in production! -# -version: "3" +version: '3.3' + services: - # Development service - development: - build: - context: . - # Build the image using the host network - # This is to allow building the image on eduroam (since it clashes with the default docker range) - network: host - # Development build - target: development - ports: - # adams.ugent.be only support port 3000 for authentication in localhost - - "3000:80" + db: + image: postgres:16 + environment: + POSTGRES_DB: tap + POSTGRES_USER: postgres + POSTGRES_PASSWORD: password volumes: - # Mount the source code for development - - "./:/tap/" + - tap_data:/var/lib/postgresql/data + ports: + - "5432:5432" + + db-test: + image: postgres:16 environment: - # Enable docker buildkit caching between layers - BUILDKIT_INLINE_CACHE: 1 - tmpfs: - - /tap/tmp + POSTGRES_DB: tap-test + POSTGRES_USER: postgres + POSTGRES_PASSWORD: password + volumes: + - tap_test_data:/var/lib/postgresql/data + ports: + - "5433:5432" + + redis: + image: redis:7-alpine + volumes: + - redis_data:/data + ports: + - "6379:6379" + +volumes: + tap_data: + tap_test_data: + redis_data: diff --git a/lib/capistrano/tasks/delayed_job.cap b/lib/capistrano/tasks/delayed_job.cap deleted file mode 100644 index 3a206b66..00000000 --- a/lib/capistrano/tasks/delayed_job.cap +++ /dev/null @@ -1,44 +0,0 @@ -namespace :delayed_job do - - def args - fetch(:delayed_job_args, "") - end - - def delayed_job_roles - fetch(:delayed_job_server_role, :app) - end - - desc 'Stop the delayed_job process' - task :stop do - on roles(delayed_job_roles) do - within release_path do - with rails_env: fetch(:rails_env) do - execute :ruby, 'bin/delayed_job', :stop - end - end - end - end - - desc 'Start the delayed_job process' - task :start do - on roles(delayed_job_roles) do - within release_path do - with rails_env: fetch(:rails_env) do - execute :ruby, 'bin/delayed_job', args, :start - end - end - end - end - - desc 'Restart the delayed_job process' - task :restart do - on roles(delayed_job_roles) do - within release_path do - with rails_env: fetch(:rails_env) do - execute :ruby, 'bin/delayed_job', args, :restart - end - end - end - end - -end diff --git a/lib/capistrano/tasks/logs.cap b/lib/capistrano/tasks/logs.cap deleted file mode 100644 index 4855a5d8..00000000 --- a/lib/capistrano/tasks/logs.cap +++ /dev/null @@ -1,8 +0,0 @@ -namespace :logs do - desc "tail rails logs" - task :tail do - on roles(:app) do - execute "tail -f #{shared_path}/log/#{fetch(:rails_env)}.log" - end - end -end