How To Integrate Ruby Daemons

Cryptex Technologies
1 min readApr 15, 2021

Ruby Daemon:

Ruby Daemons provide an easy way to wrap existing Ruby scripts or records to be run as a daemon process. They can be controlled by simple start/stop/restart commands. They also offer many advanced features like exception backtracking, monitoring and automatic restarting of the processes if it crashes. In Rails applications, Ruby Daemons are used to run background tasks.

Installation and Generation:

For creating Daemon for a Rails application, the first step is to install daemons-rails gem as mentioned:

gem ‘daemons-rails’

Run the bundle installs command on the terminal:

bundle install

After successful bundle installation, the next step is to generate daemon:

rails generate daemon <daemon_name>

The above command generates daemon_name.rb and daemon_name_ctl files in the lib/daemons/ directory along with the log file and pids in the general log folder.

Control commands of daemons include:

  • bundle exec rake daemon:daemon_name:start
  • bundle exec rake daemon:daemon_name:stop
  • bundle exec rake daemon:daemon_name:restart
  • bundle exec rake daemon:daemon_name:status

or the following commands can be utilized to start and stop the daemons:

  • bundle exec rake daemons:start
  • bundle exec rake daemons:stop

For Reading the full blog Click Here

--

--

Cryptex Technologies

Cryptex specializes in developing open source web applications and software solutions across all domains and verticals using Ruby on Rails (ROR) technology