Giter Club home page Giter Club logo

parakeet's Introduction

Parakeet

A framework for creating Ruby background processes that can be started, stopped, or run in interactive mode for debugging.

Usage

To create a process it's necessary to define a main process that will run. The most minimal form is this:

require 'parakeet'

Parakeet::Instance.new.main do
  loop do
    puts "Main process."

    sleep(1)
  end
end.parse!(ARGV)

It's necessary to have some kind of event-loop running if this process is to be persistent otherwise that block will terminate prematurely.

If this is saved in example.rb then this program can be launched:

ruby example.rb run

In this mode the output from the program is directed to the console. To stop the process use ^C.

It can also be run as a background process if the location of any log files and the PID file used to track status are defined:

require 'parakeet'

Parakeet::Instance.new.options do |program, options|
  options.pid_path = 'example.pid'
  options.log_path = 'example.log'
end.main do
  loop do
    puts "Main process."

    sleep(1)
  end
end.parse!(ARGV)

Then this can be launched as a background process:

ruby example.rb start

Which, once running, will log to that directory instead of STDOUT. The status of this process can be checked:

ruby example.rb status

You can also stop this process any time:

ruby example.rb stop

If the process finishes normally, that is does not return a non-zero exit code, then it's presumed that the shutdown was deliberate and the process is allowed to stop. If not, it's presumed there was an error or exception and after a short delay it's restarted.

parakeet's People

Contributors

tadman avatar clarkyx avatar

Stargazers

 avatar

Watchers

Dominic Bortolussi avatar James Cloos avatar  avatar

parakeet's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.