Awesome server status message

Image for post
Image for post

Most of us we do not care about server status when server is up or down, some of us even did not care about wrong routes messages like page not found 404. recently i worked in a project and i was responsible about server side, we are using rails api as back-end, i was facing server down issue in staging due of fetching huge data from third-party and the server was very small. i used to check the server every time i got response in late and if the server is down or not i was ending up with json response if the server is not down like

{"success":true,"message":"Amyal backend server is up","version":null,"env":"development"}
Image for post
Image for post

I decided to render awesome html page that make me happy when the server is up instead of rendering json response.

My app was totally rails api project so i created one controller that inherits from ActionController::Base

class PagesController < ActionController::Base; end

and rest of the controllers will inherit from ActionController::API

class ApplicationController < ActionController::API; end

app/controllers/pages_controller.rb

# frozen_string_literal: true

and we added some html and css code in our view

app/views/pages/status.html.erb

<!doctype html>

Now check localhost:3000 to see the result

Self-Taught Back-End Developer || Aspiring Full-Stack Developer || Tech enthusiast || Big fans of FC. Barcelona.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store