= App::Service
A library for service application daemonize.
== Features
- Easy switch from terminal application to background service.
== Installation
Add this line to your app's Gemfile:
[source,ruby]
gem 'app-service'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install app-service
or
$ gem install -l app-service-x.x.x.gem
== Usage
=== Example
[source,ruby]
require "app/service"
execute service application with default settings.
App::Service.setup( ARGV.shift )
execute service application with custom settings.
App::Service.setup( ARGV.shift, **options )
[source,bash]
run on terminal application.
ruby sample.rb run
start background service.
ruby sample.rb start
stop background service.
ruby sample.rb stop
restart background service.
ruby sample.rb restart
show status of background service.
ruby sample.rb status
== Reference
=== Setup App::Service.
[source,ruby]
App::Service.setup( mode = nil, **options )
-
Result:
** none.
-
Parameter:
** mode: Run mode. [run start stop restart status]
** argv: Commandline arguments. (default: ARGV)
** app_dir: Application working directory. (default: "..")
** tmp_dir: Temporary directory. (default: "tmp")
** log_dir: Logging directory. (default: "log")
** log_sync: Logging sync mode. (default: false)
** shift_age: Log file count, or log change event.
[0.., "daily", "weekly", "monthly"] (default: 0)
** shift_size: Log rotation limit size. (default: 1048576)
** log_level: Log level. (default: Logger::Severity::DEBUG)
[0:DEBUG, 1:INFO, 2:WARN, 3:ERROR, 4:FATAL, 5:UNKNOWN]
** progname: (default: nil)
** formatter: (default: Formatter.new)
** datetime_format: (default: '%Y-%m-%d %H:%M:%S')
** shift_period_suffix: (default: '%Y%m%d')
=== Shutdown App::Service.
[source,ruby]
App::Service.shutdown( cond = 0 )
=== Get run mode.
[source,ruby]
App::Service.mode
=== Get logger instance.
[source,ruby]
App::Service.logger
== Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/arimay/app-service.
== License
The gem is available as open source under the terms of the http://opensource.org/licenses/MIT[MIT License].
Copyright (c) ARIMA Yasuhiro arima.yasuhiro@gmail.com