mirror of
https://github.com/fluent/fluentd-ui.git
synced 2025-08-16 03:07:06 +02:00
Merge pull request #24 from treasure-data/fluentd_ui_options
Add subcommands to bin/fluentd-ui
This commit is contained in:
commit
cb750abd00
@ -18,6 +18,7 @@ PATH
|
||||
settingslogic
|
||||
sqlite3
|
||||
sucker_punch (~> 1.0.5)
|
||||
thor
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
|
14
README.md
14
README.md
@ -1,6 +1,6 @@
|
||||
# fluentd-ui
|
||||
|
||||
fluentd-ui is a browser-based [fluentd](http://fluentd.org/) and [td-agent](http://docs.treasuredata.com/articles/td-agent) manager than can following operations.
|
||||
fluentd-ui is a browser-based [fluentd](http://fluentd.org/) and [td-agent](http://docs.treasuredata.com/articles/td-agent) manager that can following operations.
|
||||
|
||||
* Install, uninstall, and upgrade fluentd plugins
|
||||
* start/stop/restart fluentd process
|
||||
@ -9,10 +9,14 @@ fluentd-ui is a browser-based [fluentd](http://fluentd.org/) and [td-agent](http
|
||||
|
||||
# Getting Started
|
||||
|
||||
$ gem install fluentd-ui
|
||||
$ fluentd-ui
|
||||
# Open http://localhost:9292/ by your browser
|
||||
# default account is username="admin" and password="changeme"
|
||||
```console
|
||||
$ gem install fluentd-ui
|
||||
$ fluentd-ui setup
|
||||
create DB, create initial user, etc.
|
||||
$ fluentd-ui start
|
||||
Open http://localhost:9292/ by your browser
|
||||
default account is username="admin" and password="changeme"
|
||||
```
|
||||
|
||||
Or, for developers.
|
||||
|
||||
|
@ -1,11 +1,13 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require "securerandom"
|
||||
require "thor"
|
||||
|
||||
dir = File.expand_path("../../", __FILE__)
|
||||
ENV["BUNDLE_GEMFILE"] ||= File.join(dir, "Gemfile.production")
|
||||
ENV["SECRET_KEY_BASE"] ||= SecureRandom.hex(64)
|
||||
ENV["RAILS_ENV"] ||= "production"
|
||||
system(*%W(bundle install))
|
||||
system(*%W(bundle exec rake db:create db:migrate db:seed))
|
||||
system(*%W(bundle exec rackup -E production #{dir}/config.ru))
|
||||
|
||||
require File.join(dir, "lib/fluentd-ui/command.rb")
|
||||
|
||||
FluentdUI::Command.start(ARGV)
|
||||
|
@ -34,4 +34,5 @@ Gem::Specification.new do |spec|
|
||||
spec.add_dependency "httpclient"
|
||||
spec.add_dependency "settingslogic"
|
||||
spec.add_dependency "puma"
|
||||
spec.add_dependency "thor"
|
||||
end
|
||||
|
60
lib/fluentd-ui/command.rb
Normal file
60
lib/fluentd-ui/command.rb
Normal file
@ -0,0 +1,60 @@
|
||||
module FluentdUI
|
||||
class Command < Thor
|
||||
ROOT = File.expand_path('../../../', __FILE__)
|
||||
|
||||
|
||||
desc "start", "start fluentd-ui server"
|
||||
option :port, type: :numeric, default: 9292
|
||||
option :pidfile, type: :string, default: File.expand_path('tmp/fluentd-ui.pid', ROOT)
|
||||
option :daemonize, type: :boolean, default: false
|
||||
def start
|
||||
# NOTE: When fluentd-ui gem updated, it may have new migrations.
|
||||
# do `setup` before `start` solve that, but currently don't. should decide later.
|
||||
# setup
|
||||
system(*%W(bundle exec rackup #{options[:daemonize] ? "-D" : ""} --pid #{options[:pidfile]} -p #{options[:port]} -E production #{ROOT}/config.ru))
|
||||
end
|
||||
|
||||
|
||||
desc "stop", "stop fluentd-ui server"
|
||||
option :pidfile, type: :string, default: File.expand_path('tmp/fluentd-ui.pid', ROOT)
|
||||
def stop
|
||||
Process.kill(:TERM, pid) if pid
|
||||
rescue Errno::ESRCH
|
||||
ensure
|
||||
puts "stopped"
|
||||
end
|
||||
|
||||
|
||||
desc "status", "status of fluentd-ui server"
|
||||
option :pidfile, type: :string, default: File.expand_path('tmp/fluentd-ui.pid', ROOT)
|
||||
def status
|
||||
if pid && Process.kill(0, pid)
|
||||
puts "fluentd-ui is running"
|
||||
else
|
||||
puts "fluentd-ui is stopped"
|
||||
end
|
||||
rescue Errno::ESRCH
|
||||
puts "fluentd-ui is stopped"
|
||||
end
|
||||
|
||||
|
||||
desc "setup", "setup fluentd-ui server"
|
||||
long_desc <<-DESC
|
||||
1. install dependency gems
|
||||
|
||||
2. create DB
|
||||
|
||||
3. create initial user if no user registered
|
||||
DESC
|
||||
def setup
|
||||
system(*%W(bundle install))
|
||||
system(*%W(bundle exec rake db:create db:migrate db:seed))
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def pid
|
||||
File.read(options[:pidfile]).to_i rescue nil
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user