focuslight 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bba36269e54dd1576dea78ca16c3fd5a18aeef05
4
- data.tar.gz: 21bfc8d84524e5362e04a08eb8b17a90c02000ed
3
+ metadata.gz: 8baaac32f2c61d12d953da8bc50a964f52c0305f
4
+ data.tar.gz: aaade6440a9e2f54d60a81ecf735d24c1f58da20
5
5
  SHA512:
6
- metadata.gz: 16ab8bc51012ffcb268a858e2756503d0b8f54ec095eda64db9bd9858e184fa5c94a68eefa61d547608af95fdbf64c49e4592c568ca2fa110fa194bbb252a80e
7
- data.tar.gz: d23d1cd4857666be4a35b7345cab1baeb902b6add1c94f2ae3eba647d0eb89e13443a56080a84d46144cc67924172ec806a361f33c96dd6f8f0c3d3b16f41219
6
+ metadata.gz: 984b5ea208adfd11c62806217d79fe78e989ec550904d60d0264e664e556e8ddec24f6a7e5f9e6d87dc2654ed4c2467103f2b7213dbe8daa60b717f807f70b59
7
+ data.tar.gz: 9ed76a9f4ca56a7de47333f5d5bb3ddceca1217c1479d4385982b40bb29618a2e31008e9f689b5ceb320d80f589c73695fda9a1b09835db85b612851b7f96363
data/.gitignore CHANGED
@@ -19,3 +19,4 @@ data/
19
19
  .ruby-version
20
20
  log/
21
21
  *.log
22
+ focuslight/
data/.travis.yml CHANGED
@@ -6,4 +6,4 @@ gemfile:
6
6
  before_install:
7
7
  - sudo apt-get install rrdtool librrd-dev
8
8
  before_script:
9
- - bundle exec rake init
9
+ - bundle exec focuslight init
data/CHANGELOG.md CHANGED
@@ -1,4 +1,8 @@
1
- # 0.1.2 (2014/02/27)
1
+ # 0.1.3 (2014/03/24)
2
+
3
+ Enhancements:
4
+
5
+ * Use unicorn-worker-killer
2
6
 
3
7
  Fixes:
4
8
 
data/Procfile CHANGED
@@ -1,3 +1,3 @@
1
1
  web: bundle exec unicorn -E production -p $PORT -o $HOST
2
- worker1: bundle exec rake longer
3
- worker2: bundle exec rake shorter
2
+ worker1: bundle exec focuslight longer
3
+ worker2: bundle exec focuslight shorter
data/README.md CHANGED
@@ -25,33 +25,40 @@ RRDTool and its dependencies must be installed before installing Focuslight.
25
25
 
26
26
  ## Installation
27
27
 
28
- Install focuslight with Ruby 2.0 or later. Execute after installation.
28
+ Install focuslight with Ruby 2.0 or later.
29
29
 
30
- ### Using gem package
30
+ ### Gem package
31
31
 
32
- Four easy steps installation with gem.
32
+ Five easy steps on installation with gem and SQLite.
33
33
 
34
- 1. `gem install focuslight`
35
- 2. `focuslight new` # creates focuslight resource in `pwd`/focuslight
36
- 3. `focuslight init` # creates database scheme
37
- 4. `focuslight start`
34
+ ```bash
35
+ $ gem install focuslight
36
+ $ focuslight new
37
+ $ cd focuslight
38
+ $ focuslight init # creates database scheme on SQLite
39
+ $ focuslight start
40
+ ```
41
+
42
+ Then see `http://localhost:5125/`. Refer `Using MySQL` section to use MySQL instead of SQLite.
38
43
 
39
- Then see `http://localhost:5125/`
44
+ ### Git repository
40
45
 
41
- ### Using SQLite:
46
+ Install from git repository.
42
47
 
43
- 1. clone this repository
44
- 1. `cd focuslight`
45
- 1. install dependencies: `bundle install`
46
- 1. initialize database: `bundle exec rake init`
47
- 1. execute: `bundle exec foreman start`
48
+ ```bash
49
+ $ git clone https://github.com/focuslight/focuslight.git
50
+ $ cd focuslight
51
+ $ bundle
52
+ $ bundle exec focuslight init # creates database scheme on SQLite
53
+ $ bundle exec focuslight start
54
+ ```
48
55
 
49
- Then see `http://localhost:5125/`
56
+ Then see `http://localhost:5125/`. Refer `Using MySQL` section to use MySQL instead of SQLite.
50
57
 
51
- ### Using MySQL:
58
+ ### Using MySQL
52
59
 
53
- You need to change DBURL parameter on .env file to `mysql2` version.
54
- You may also configure the database name, the user name, and the password. See the Configuration section.
60
+ Change `DBURL` parameter on .env file to `mysql2` version like `DBURL=mysql2://root:@localhost/focuslight`.
61
+ Also configure the database name, the user name, and the password. See the Configuration section.
55
62
 
56
63
  Then, create the database and assign permissions to the user as
57
64
 
@@ -61,7 +68,7 @@ mysql> GRANT CREATE, ALTER, DELETE, INSERT, UPDATE, SELECT \\
61
68
  ON focuslight.* TO 'user'\@'localhost' IDENTIFIED BY password;
62
69
  ```
63
70
 
64
- Then, do the same thing with SQLite case.
71
+ After that, follow the same procedure with the SQLite case.
65
72
 
66
73
  ## Configuration
67
74
 
@@ -100,9 +107,9 @@ LOG_LEVEL=warn
100
107
  * Daemonize support
101
108
  * Add tests, and tests, and more tests
102
109
 
103
- ## Imcompatible Features
110
+ ## Incompatible Features
104
111
 
105
- Focuslight has following incompatibilitie with GrowthForecast as specifications.
112
+ Focuslight has following incompatibilities with GrowthForecast as specifications.
106
113
 
107
114
  ### Subtract
108
115
 
data/Rakefile CHANGED
@@ -10,12 +10,6 @@ end
10
10
  lib = File.expand_path('../lib', __FILE__)
11
11
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
12
12
  require 'dotenv/tasks'
13
- require "focuslight/worker"
14
-
15
- task :init => :dotenv do
16
- require "focuslight/init"
17
- Focuslight::Init.run
18
- end
19
13
 
20
14
  task :console => :dotenv do
21
15
  require "focuslight/init"
@@ -26,13 +20,5 @@ task :console => :dotenv do
26
20
  end
27
21
  task :c => :console
28
22
 
29
- task :longer => :dotenv do
30
- Focuslight::Worker.run(interval: 300, target: :normal)
31
- end
32
-
33
- task :shorter => :dotenv do
34
- Focuslight::Worker.run(interval: 60, target: :short)
35
- end
36
-
37
23
  task :test => :spec
38
24
  task :default => :spec
data/config.ru CHANGED
@@ -1,6 +1,15 @@
1
1
  require "rubygems"
2
2
  require "sinatra"
3
+ require "focuslight"
4
+ require "focuslight/web"
3
5
 
4
- require File.expand_path '../lib/focuslight/web.rb', __FILE__
6
+ # Unicorn self-process killer
7
+ require 'unicorn/worker_killer'
8
+
9
+ # Max requests per worker
10
+ use Unicorn::WorkerKiller::MaxRequests, 3072, 4096
11
+
12
+ # Max memory size (RSS) per worker
13
+ use Unicorn::WorkerKiller::Oom, (192*(1024**2)), (256*(1024**2))
5
14
 
6
15
  run Focuslight::Web
data/focuslight.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Focuslight::VERSION
9
9
  spec.authors = ["TAGOMORI Satoshi", "Naotoshi Seo", "Shota Fukumori (sora_h)"]
10
10
  spec.email = ["tagomoris@gmail.com", "sonots@gmail.com", "her@sorah.jp"]
11
- spec.description = %q{Ruby port of GrowthForecast}
12
- spec.summary = %q{Lightning Fast Graphing/Visualization}
11
+ spec.description = %q{Lightning Fast Graphing/Visualization, built on RRDTool}
12
+ spec.summary = %q{Lightning Fast Graphing/Visualization, built on RRDTool}
13
13
  spec.homepage = "https://github.com/tagomoris/focuslight"
14
14
  spec.license = "MIT"
15
15
 
@@ -33,6 +33,7 @@ Gem::Specification.new do |spec|
33
33
  spec.add_runtime_dependency "sinatra-contrib"
34
34
  spec.add_runtime_dependency "erubis"
35
35
  spec.add_runtime_dependency "unicorn"
36
+ spec.add_runtime_dependency "unicorn-worker-killer"
36
37
 
37
38
  spec.add_runtime_dependency "sequel"
38
39
  spec.add_runtime_dependency "sqlite3"
@@ -11,6 +11,8 @@ class Focuslight::CLI < Thor
11
11
  LOG_DIR = File.join(BASE_DIR, "log")
12
12
  LOG_FILE = File.join(LOG_DIR, "application.log")
13
13
  ENV_FILE = File.join(BASE_DIR, ".env")
14
+ PROCFILE = File.join(BASE_DIR, "Procfile")
15
+ CONFIGRU_FILE = File.join(BASE_DIR, "config.ru")
14
16
 
15
17
  DEFAULT_DOTENV =<<-EOS
16
18
  DATADIR=#{DATA_DIR}
@@ -26,62 +28,50 @@ DBURL=#{DBURL}
26
28
  # MOUNT=/
27
29
  LOG_PATH=#{LOG_FILE}
28
30
  LOG_LEVEL=warn
31
+ EOS
32
+
33
+ DEFAULT_PROCFILE =<<-EOS
34
+ web: unicorn -E production -p $PORT -o $HOST
35
+ worker1: focuslight longer
36
+ worker2: focuslight shorter
29
37
  EOS
30
38
 
31
39
  default_command :start
32
40
 
33
- desc "new", "Creating focuslight resource directory"
41
+ desc "new", "Creates focuslight resource directory"
34
42
  def new
35
43
  FileUtils.mkdir_p(LOG_DIR)
36
44
  File.write ENV_FILE, DEFAULT_DOTENV
45
+ File.write PROCFILE, DEFAULT_PROCFILE
46
+ configru_file = File.expand_path("../../../config.ru", __FILE__)
47
+ FileUtils.copy(configru_file, CONFIGRU_FILE)
37
48
  end
38
49
 
39
- desc "init", "Creating database schema"
50
+ desc "init", "Creates database schema"
40
51
  def init
41
- abort "\"#{ENV_FILE}\" is not found. Run `focuslight new` first" unless File.exist? ENV_FILE
42
-
43
- Dotenv.load ENV_FILE
52
+ Dotenv.load
44
53
  require "focuslight/init"
45
54
  Focuslight::Init.run
46
55
  end
47
56
 
48
57
  desc "start", "Sartup focuslight"
49
58
  def start
50
- abort "\"#{ENV_FILE}\" is not found. Run `focuslight new` first" unless File.exist? ENV_FILE
51
-
52
- Dotenv.load ENV_FILE
59
+ Dotenv.load
53
60
  require "foreman/cli"
54
- procfile = File.expand_path("../../../Procfile-gem", __FILE__)
55
- Foreman::CLI.new.invoke(:start, [], procfile: procfile)
61
+ Foreman::CLI.new.invoke(:start, [], {})
56
62
  end
57
63
 
58
64
  desc "longer", "Startup focuslight longer worker"
59
65
  def longer
60
- abort "\"#{ENV_FILE}\" is not found. Run `focuslight new` first" unless File.exist? ENV_FILE
61
-
62
- Dotenv.load ENV_FILE
66
+ Dotenv.load
63
67
  require "focuslight/worker"
64
68
  Focuslight::Worker.run(interval: 300, target: :normal)
65
69
  end
66
70
 
67
71
  desc "shorter", "Startup focuslight shorter worker"
68
72
  def shorter
69
- abort "\"#{ENV_FILE}\" is not found. Run `focuslight new` first" unless File.exist? ENV_FILE
70
-
71
- Dotenv.load ENV_FILE
73
+ Dotenv.load
72
74
  require "focuslight/worker"
73
75
  Focuslight::Worker.run(interval: 60, target: :short)
74
76
  end
75
-
76
- #desc "web", "Startup focuslight web server"
77
- #def web
78
- # ToDo
79
- #end
80
-
81
- no_tasks do
82
- def abort(msg)
83
- $stderr.puts msg
84
- exit 1
85
- end
86
- end
87
77
  end
@@ -1,3 +1,3 @@
1
1
  module Focuslight
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/spec/cli_spec.rb ADDED
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+ require 'focuslight/cli'
3
+
4
+ describe Focuslight::CLI do
5
+ let(:cli) { Focuslight::CLI.new }
6
+
7
+ context "#new" do
8
+ before { cli.invoke(:new) }
9
+ it {
10
+ expect(Dir.exists?(Focuslight::CLI::BASE_DIR)).to be_true
11
+ expect(Dir.exists?(Focuslight::CLI::LOG_DIR)).to be_true
12
+ expect(File.read(Focuslight::CLI::ENV_FILE)).to eql(Focuslight::CLI::DEFAULT_DOTENV)
13
+ expect(File.read(Focuslight::CLI::PROCFILE)).to eql(Focuslight::CLI::DEFAULT_PROCFILE)
14
+ expect(File.exists?(Focuslight::CLI::CONFIGRU_FILE)).to be_true
15
+ }
16
+ after { FileUtils.remove_dir(Focuslight::CLI::BASE_DIR) }
17
+ end
18
+
19
+ context "#init" do
20
+ before {
21
+ cli.invoke(:new)
22
+ Dir.chdir(Focuslight::CLI::BASE_DIR) {|path|
23
+ cli.invoke(:init)
24
+ }
25
+ }
26
+ it { expect(Dir.exists?(Focuslight::CLI::DATA_DIR)).to be_true }
27
+ after { FileUtils.remove_dir(Focuslight::CLI::BASE_DIR) }
28
+ end
29
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: focuslight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - TAGOMORI Satoshi
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-02-27 00:00:00.000000000 Z
13
+ date: 2014-03-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -194,6 +194,20 @@ dependencies:
194
194
  - - '>='
195
195
  - !ruby/object:Gem::Version
196
196
  version: '0'
197
+ - !ruby/object:Gem::Dependency
198
+ name: unicorn-worker-killer
199
+ requirement: !ruby/object:Gem::Requirement
200
+ requirements:
201
+ - - '>='
202
+ - !ruby/object:Gem::Version
203
+ version: '0'
204
+ type: :runtime
205
+ prerelease: false
206
+ version_requirements: !ruby/object:Gem::Requirement
207
+ requirements:
208
+ - - '>='
209
+ - !ruby/object:Gem::Version
210
+ version: '0'
197
211
  - !ruby/object:Gem::Dependency
198
212
  name: sequel
199
213
  requirement: !ruby/object:Gem::Requirement
@@ -264,7 +278,7 @@ dependencies:
264
278
  - - '>='
265
279
  - !ruby/object:Gem::Version
266
280
  version: '0'
267
- description: Ruby port of GrowthForecast
281
+ description: Lightning Fast Graphing/Visualization, built on RRDTool
268
282
  email:
269
283
  - tagomoris@gmail.com
270
284
  - sonots@gmail.com
@@ -281,7 +295,6 @@ files:
281
295
  - Gemfile
282
296
  - LICENSE.txt
283
297
  - Procfile
284
- - Procfile-gem
285
298
  - README.md
286
299
  - Rakefile
287
300
  - bin/focuslight
@@ -311,6 +324,7 @@ files:
311
324
  - public/js/jquery-1.10.2.min.map
312
325
  - public/js/jquery.storageapi.min.js
313
326
  - public/js/site.js
327
+ - spec/cli_spec.rb
314
328
  - spec/spec_helper.rb
315
329
  - spec/syntax_spec.rb
316
330
  - spec/validator_predefined_rules_spec.rb
@@ -349,8 +363,9 @@ rubyforge_project:
349
363
  rubygems_version: 2.0.3
350
364
  signing_key:
351
365
  specification_version: 4
352
- summary: Lightning Fast Graphing/Visualization
366
+ summary: Lightning Fast Graphing/Visualization, built on RRDTool
353
367
  test_files:
368
+ - spec/cli_spec.rb
354
369
  - spec/spec_helper.rb
355
370
  - spec/syntax_spec.rb
356
371
  - spec/validator_predefined_rules_spec.rb
data/Procfile-gem DELETED
@@ -1,3 +0,0 @@
1
- web: unicorn -E production -p $PORT -o $HOST
2
- worker1: focuslight longer
3
- worker2: focuslight shorter