• Stars
    star
    125
  • Rank 279,198 (Top 6 %)
  • Language
    Ruby
  • License
    The Unlicense
  • Created almost 12 years ago
  • Updated about 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A simpler way to create Ruby fallen ængels, better known as dæmons

Fallen

A simpler daemon library for Ruby processes.

Usage

require "fallen"

module Azazel
  extend Fallen
  
  def self.run
    while running?
      puts "Time is on my side... Yes it is..."
      sleep 666
    end
  end
end

Azazel.start!

This will print Time is on my side... Yes it is.. every 666 seconds on STDOUT. You can stop the daemon by pressing CTRL+c.

Control your daemon

Fallen accepts the following methods:

  • daemonize!: detaches the process and keep running it on background;
  • chdir!: changes the current working directory of the process (useful for log and pid files);
  • pid_file: allows to indicate a file path where the daemon PID will be stored; could be either an absolute path or a relative path to the current working directory (see chdir!);
  • stdout, stderr & stdin: redirects the process STDOUT, STDERR and STDIN to either an absolute or relative file path; note that when a process is daemonized by default all these streams are redirected to /dev/null.

For example, the previous example could have the following lines before Azazel.start! to store the PID and log to a file:

Azazel.pid_file "/var/run/azazel.pid"
Azazel.stdout "/var/log/azazel.log"
Azazel.daemonize!
Azazel.start!

CLI support

Fallen supports command line parameters, by default using the clap gem. In order to enable command line support you need to do the following:

require "fallen"
require "fallen/cli"

module Azazel
  extend Fallen
  extend Fallen::CLI
  
  # ...
  
  def usage
    puts "..." # Your usage message
    # Default Fallen usage options
    puts fallen_usage
  end
end

case Clap.run(ARGV, Azazel.cli).first
when "start"
  Azazel.start!
when "stop"
  Azazel.stop!
else
  Azazel.usage
end

Azazel.usage will print the following:

Fallen introduced command line arguments:

  -D    Daemonize this process
  -C    Change directory.
  -P    Path to PID file. Only used in daemonized process.
  -out  Path to redirect STDOUT.
  -err  Path to redirect STDERR.
  -in   Path to redirect STDIN.

License

See the UNLICENSE file included with this gem distribution.

More Repositories

1

github-issues.el

github-issues.el --- Emacs utility functions and modes for managing GitHub projects' issues
Emacs Lisp
48
star
2

haproxy-ruby

Ruby gem for interfacing with HAProxy
Ruby
44
star
3

viaproxy

Proxy Protocol support for Go net.Conn
Go
24
star
4

ruster

Control your Redis Cluster from the command line
Ruby
21
star
5

cmd2slack

Execute a command and send its output to Slack
Go
20
star
6

hubot-slack-attachment

Re-enable `slack-attachment` event for hubot-slack
CoffeeScript
18
star
7

hubot-jenkins-slack

Jenkins notifier adapted for Slack
CoffeeScript
16
star
8

disyuntor

Simple Circuit Breaker pattern in Ruby
Ruby
15
star
9

spdy-examples

SPDY Ruby server examples
Ruby
11
star
10

gedis

gedis - a Redis client written in Go
Go
10
star
11

crystal-prometheus-client

Prometheus client for Crystal
Crystal
5
star
12

slacker

Slack CLI to update status and presence
Go
5
star
13

prefix

DRY
Go
5
star
14

lruc

Reverse cURL: one liner HTTP server with deep response configuration
Go
5
star
15

andale

Ándale: a simple SPDY framework
Ruby
4
star
16

redic-cluster

Redis Cluster support for Redic
Ruby
4
star
17

emacs-d

My emacs configuration
Emacs Lisp
3
star
18

dotfiles

Shell
3
star
19

groupchat

Simple HTML5 + Node.js + Socket.io + Redis proof of concept application for enabling group chat.
3
star
20

grafana-terraform-webinar-demo

Terraform files for a webinar demo of managing your Grafana resources using Terraform
HCL
3
star
21

escat

Query Elasticsearch cat APIs with ease and joy.
Go
2
star
22

exex

Extensions for exec.Command to automatically capture stderr on Run.
Go
2
star
23

sbs

Output two files side by side
Go
2
star
24

bsort

Like sort(1) but keeping the first line as headers.
Go
2
star
25

haproxy-mobile-frontend

Mobile frontend to HAProxy statistics
Ruby
2
star
26

mote-mode

Emacs minor mode for editing Mote templates
Emacs Lisp
1
star
27

shield

Go port of Ruby's Shield
Go
1
star
28

dd-mobile-slides

Slides for my Design and Development for Mobile talk at my current office
Ruby
1
star
29

cubalibre

Simple CLI parser inspired by cuba simplicity
Ruby
1
star
30

asset

Plugin to improve assets management in CakePHP projects
1
star
31

inkel.github.io

HTML
1
star
32

consul-catalog

Queries Consul catalog and print out registered nodes and services. Useful for tab completion.
Go
1
star
33

talks

Talks by Leandro López (inkel)
Ruby
1
star
34

Leiden-2.0

Source code of my travel blog
Ruby
1
star
35

cuba-omniauth-octokit

Proof of concept of a Cuba application with OmniAuth and Octokit to access the GitHub v3 API
JavaScript
1
star