Cristof' page

Basically my own tips & tricks I use regularly when coding or setting up my servers on DigitalOcean && some OSS stuff.

Move to Fullstasq Ruby

Add CentOS package (fullstaq-ruby-2.7-jemalloc) 1.- Add /usr/lib/fullstaq-ruby/versions/2.7-jemalloc/bin/ to path 2.- bundle install 3.- Update ruby path for passenger 4.- Update ruby path for Sidekiq

Mute warnings when using Ruby 2.7

Edit $HOME/.profile and then source $HOME/.profile export RUBYOPT='-W:no-deprecated -W:no-experimental'

Profiling Sidekiq with Skylight

Edit config/skylight.yml authentication: TOKEN enable_sidekiq: true

Migrate to Postgresql 12

$ sudo su - postgres $ # dump your pg_hba.conf and postgresql.conf $ /usr/pgsql-12/bin/initdb -D /var/lib/pgsql/12/data/ /usr/pgsql-12/bin/pg_upgrade --old-bindir=/usr/pgsql-11/bin/ \ --new-bindir=/usr/pgsql-12/bin/ \ --old-datadir=/var/lib/pgsql/11/data/ --new-datadir=/var/lib/pgsql/12/data/ --check $ /usr/pgsql-12/bin/pg_upgrade --old-bindir=/usr/pgsql-11/bin/ \ --new-bindir=/usr/pgsql-12/bin/ --old-datadir=/var/lib/pgsql/11/data/ \ --new-datadir=/var/lib/pgsql/12/data/ --link $ ./ $ ./ $ reindexdb --all --concurrently $ # check changes for ph_hba.conf and postgresql.conf $ # restart server && enjoy!

Using devise helpers on IntegrationTest

Edit test_helper.rb

ENV['RAILS_ENV'] ||= 'test' require_relative '../config/environment' require 'rails/test_help' class ActiveSupport::TestCase # Run tests in parallel with specified workers parallelize(workers: 1) # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. fixtures :all # Add more helper methods to be used by all tests here... end class ActionDispatch::IntegrationTest include Devise::Test::IntegrationHelpers end

System Tests

Edit application_system_test_case.rb

require "test_helper" class ApplicationSystemTestCase < ActionDispatch::SystemTestCase include Devise::Test::IntegrationHelpers # If you want to actually open chrome and see the interactions: # driven_by :selenium, using: :chrome, screen_size: [1400, 1400] driven_by :selenium, using: :headless_chrome end

Postgres' gem

Having postgresql11-devel

gem install pg -- --with-pg-config=/usr/pgsql-11/bin/pg_config

Postgres' configuration

Settings you should tune according to your hardware and OS


Passenger: Upgrading ruby version

Edit /etc/nginx/conf.d/passenger.conf and give the corresponding path on passenger_ruby

Sidekiq: Upgrading ruby version

Edit /usr/lib/systemd/system/sidekiq.service and check path on ExecStart

Passenger: some commands

Status (as root) passenger-status

Restart app (as regular user): bundle exec passenger-config restart-app

Free SSL: cerbot

certbot --nginx

Redis: Using LRU

Edit /etc/redis.conf and set maxmemory-policy

maxmemory-policy allkeys-lru

SSH server: non-root users

Edit /etc/ssh/sshd_config

PermitRootLogin no

AllowUsers user1 user2

Open Source contributions

Sidekiq - Add path for syslog on CentOS

Faker - adding Chilean ID

Logidze - fixing README

Doorkeeper - Forbidden when an unauthorised user tries to revoke a token

Rspotify - Add controls to the player

gmaps-marker-clusterer - Add parameters for Styles