Skip to content

Instantly share code, notes, and snippets.

View majedbojan's full-sized avatar
We turn coffee into code

MaJeD BoJaN majedbojan

We turn coffee into code
View GitHub Profile

We used the official Capistrano recipe for Puma. capistrano-puma. It has monit scripts built-in to monitor puma server processes

OS level


Install monit

sudo apt-get update
@majedbojan
majedbojan / authentication_helper.rb
Last active November 1, 2021 11:00
Add user Authentication to Rspec request
# frozen_string_literal: true
# Add `AuthenticationHelper` in spec/support/authentication_helper.rb
module AuthenticationHelper
def generate_token(user)
payload = { id: user.id.to_s }
JWT.encode payload, Rails.application.credentials.secret_key_base, 'HS256'
end
def sign_in(user)
@majedbojan
majedbojan / kill-server-process.sh
Created April 5, 2022 21:03
Solving `Address already in use - bind(2) for 127.0.0.1:4000 (Errno::EADDRINUSE)` issue
# When you didn't shutdown the server wisely,
# you will encounter error that tells you the certain port is in use
# specially when running rails server
kill -9 $(lsof -i tcp:4000 -t)
# Note:
Change the `4000` upon on the port you are running on it