back_scrape_job 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a48237e835aede0e1385eb7b58eb7fc912bfe218
4
+ data.tar.gz: 60b57d7c949b0566fc6c3722b4d19887763374b3
5
+ SHA512:
6
+ metadata.gz: e0ee9c588852caddf48f55422be431036516a63ab5fbc9ab3170701592acbea5b5a5a7c724ed9081a0c146b05e9472f49a551803c32638a9830bb306feb47f5f
7
+ data.tar.gz: f78d30cffde8b628871a7b070426d9acde826f2d13edc817b278e0e8dc6847f9c41989a31b59aaa5e968e039bae818c8679336c6171611721291d38acfd87c3b
@@ -0,0 +1,5 @@
1
+ require "back_scrape_job/version"
2
+
3
+ module BackScrapeJob
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,3 @@
1
+ module BackScrapeJob
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Explain the generator
3
+
4
+ Example:
5
+ rails generate initializer Thing
6
+
7
+ This will create:
8
+ what/will/it/create
@@ -0,0 +1,34 @@
1
+ require 'fileutils'
2
+ class InitializerGenerator < Rails::Generators::Base
3
+ source_root File.expand_path('../templates', __FILE__)
4
+
5
+ def copy_initializer_file
6
+ copy_file "backscript_controller.rb", "app/controllers/backscript_controller.rb"
7
+ copy_file "backscript_controller.rb", "app/model/backscript.rb"
8
+ directory 'backscripts', "app/views/backscripts"
9
+ copy_file "seed.rb", "db/seeds.rb"
10
+ copy_file "migration.rb", "db/migrate/#{migration_prefix}.rb"
11
+ inject_into_file 'config/routes.rb', :after => "routes.draw do" do
12
+ route_path
13
+ end
14
+
15
+ end
16
+
17
+ def route_path
18
+ "\n resources :backscripts do
19
+ get 'trigering_backscript'
20
+ end"
21
+ end
22
+
23
+ def migration_prefix
24
+ time = Time.now
25
+ year = time.strftime("%Y")
26
+ month = time.strftime("%m")
27
+ date = time.strftime("%d")
28
+ hour = time.strftime("%H")
29
+ minutes = time.strftime("%M")
30
+ seconds = time.strftime("%S")
31
+ migration_prefix = year + month + date + hour + minutes + seconds + "_create_backscripts"
32
+ end
33
+
34
+ end
@@ -0,0 +1,34 @@
1
+ require 'fileutils'
2
+ class InitializerGenerator < Rails::Generators::Base
3
+ source_root File.expand_path('../templates', __FILE__)
4
+
5
+ def copy_initializer_file
6
+ copy_file "backscript_controller.rb", "app/controllers/backscript_controller.rb"
7
+ copy_file "backscript_controller.rb", "app/model/backscript.rb"
8
+ directory 'backscripts', "app/views/backscripts"
9
+ copy_file "seed.rb", "db/seeds.rb"
10
+ copy_file "migration.rb", "db/migrate/#{migration_prefix}.rb"
11
+ inject_into_file 'config/routes.rb', :after => "routes.draw do" do
12
+ route_path
13
+ end
14
+
15
+ end
16
+
17
+ def route_path
18
+ "\n resources :backscripts do
19
+ get 'trigering_backscript'
20
+ end"
21
+ end
22
+
23
+ def migration_prefix
24
+ time = Time.now
25
+ year = time.strftime("%Y")
26
+ month = time.strftime("%m")
27
+ date = time.strftime("%d")
28
+ hour = time.strftime("%H")
29
+ minutes = time.strftime("%M")
30
+ seconds = time.strftime("%S")
31
+ migration_prefix = year + month + date + hour + minutes + seconds + "_create_backscripts"
32
+ end
33
+
34
+ end
@@ -0,0 +1,3 @@
1
+ class Backscript < ActiveRecord::Base
2
+ attr_accessible :command_name,:command,:type_of_command,:active
3
+ end
@@ -0,0 +1,3 @@
1
+ class Backscript < ActiveRecord::Base
2
+ attr_accessible :command_name,:command,:type_of_command,:active
3
+ end
@@ -0,0 +1,20 @@
1
+ class BackscriptsController < ApplicationController
2
+ load_and_authorize_resource
3
+ require 'open3'
4
+
5
+ def index
6
+ @backscripts = Backscript.all
7
+ end
8
+
9
+ def trigering_backscript
10
+ back_script = Backscript.find(params[:backscript_id])
11
+ command = back_script.command
12
+ Open3.popen3(command) do |stdin, stdout, stderr, wait_thr|
13
+ @status = stdout.read.to_s
14
+ back_script.status = "Solr is Running Successfully." if @status.include?("Dsolr.data.dir")
15
+ back_script.status = "Sidekiq is Running Successfully." if @status.include?("grep sidekiq")
16
+ back_script.save!
17
+ end
18
+ redirect_to :back
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ class BackscriptsController < ApplicationController
2
+ load_and_authorize_resource
3
+ require 'open3'
4
+
5
+ def index
6
+ @backscripts = Backscript.all
7
+ end
8
+
9
+ def trigering_backscript
10
+ back_script = Backscript.find(params[:backscript_id])
11
+ command = back_script.command
12
+ Open3.popen3(command) do |stdin, stdout, stderr, wait_thr|
13
+ @status = stdout.read.to_s
14
+ back_script.status = "Solr is Running Successfully." if @status.include?("Dsolr.data.dir")
15
+ back_script.status = "Sidekiq is Running Successfully." if @status.include?("grep sidekiq")
16
+ back_script.save!
17
+ end
18
+ redirect_to :back
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ <table class="table table-striped">
2
+ <thead>
3
+ <tr>
4
+ <th>CommandName</th>
5
+ <th>Command</th>
6
+ <th>TypeOfCommand</th>
7
+ <th>Active</th>
8
+ </tr>
9
+ </thead>
10
+ <tbody>
11
+ <% @backscripts.each do |back| %>
12
+ <tr>
13
+ <td><%= link_to back.command_name, backscript_trigering_backscript_path(back) %></td>
14
+ <td><%= back.command %></td>
15
+ <td><%= back.type_of_command %></td>
16
+ <td><%= back.active %></td>
17
+ </tr>
18
+ <% end %>
19
+ </tbody>
20
+ </table>
@@ -0,0 +1,14 @@
1
+ class CreateBackscripts < ActiveRecord::Migration
2
+ def up
3
+ create_table :backscripts do |t|
4
+ t.string :command_name
5
+ t.string :command
6
+ t.string :type_of_command
7
+ t.boolean :active
8
+ t.string :string
9
+ end
10
+ end
11
+
12
+ def down
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ class CreateBackscripts < ActiveRecord::Migration
2
+ def up
3
+ create_table :backscripts do |t|
4
+ t.string :command_name
5
+ t.string :command
6
+ t.string :type_of_command
7
+ t.boolean :active
8
+ t.string :string
9
+ end
10
+ end
11
+
12
+ def down
13
+ end
14
+ end
@@ -0,0 +1,22 @@
1
+ BACKSCRIPT_DATA = [ { :command_name => 'solr_start', :command => "cd #{Rails.root} && bundle exec rake sunspot:solr:start", :type_of_command => 'solr', :active => 'true'},
2
+ { :command_name => 'solr_stop', :command => "cd #{Rails.root} && bundle exec rake sunspot:solr:stop", :type_of_command => 'solr', :active => 'true'},
3
+ { :command_name => 'solr_status', :command => "cd #{Rails.root} && ps -ef | grep solr", :type_of_command => 'solr', :active => 'true'},
4
+ { :command_name => 'reindex_solr',:command => "cd #{Rails.root} && bundle exec rake sunspot:solr:reindex",:type_of_command => 'solr',:active => 'true'},
5
+ { :command_name => 'sidekiq_status', :command => "cd #{Rails.root} && ps -ef | grep sidekiq", :type_of_command => 'sidekiq', :active => 'true'},
6
+ { :command_name => 'sidekiq_stop', :command => "cd #{Rails.root} && rake sidekiq:stop", :type_of_command => 'sidekiq', :active => 'true' },
7
+ { :command_name => 'sidekiq_start', :command => "cd #{Rails.root} && rake sidekiq:start", :type_of_command => 'sidekiq', :active => 'true'},
8
+ { :command_name => 'sidekiq_restart', :command => "cd #{Rails.root} && rake sidekiq:restart", :type_of_command => 'sidekiq', :active => 'true' },
9
+ { :command_name => 'warc_start', :command => "cd #{Rails.root} && rake sidekiq:warc_start", :type_of_command => 'warc', :active => 'true' },
10
+ { :command_name => 'warc_stop', :command => "cd #{Rails.root} && rake sidekiq:warc_stop", :type_of_command => 'warc', :active => 'true' },
11
+ { :command_name => 'warc_restart', :command => "cd #{Rails.root} && rake sidekiq:warc_restart", :type_of_command => 'warc', :active => 'true' },
12
+ { :command_name => 'nginx_start', :command => "cd #{Rails.root} && sudo service nginx start", :type_of_command => 'nginx', :active => 'true' },
13
+ { :command_name => 'nginx_stop', :command => "cd #{Rails.root} && sudo service nginx stop", :type_of_command => 'nginx', :active => 'true' },
14
+ { :command_name => 'nginx_status',:command => "cd #{Rails.root} && sudo service nginx status",:type_of_command => 'nginx', :active => 'true' },
15
+ { :command_name => 'redis_start', :command => "cd #{Rails.root} && sudo service redis_6379 start", :type_of_command => 'redis', :active => 'true' },
16
+ { :command_name => 'redis_stop', :command => "cd #{Rails.root} && sudo service redis_6379 stop", :type_of_command => 'redis', :active => 'true' } ,
17
+ { :command_name => 'redis_status', :command => "cd #{Rails.root} && ps -ef | grep redis", :type_of_command => 'redis', :active => 'true' } ]
18
+
19
+ BACKSCRIPT_DATA.each do |backscript_params|
20
+ Backscript.create!(backscript_params)
21
+ end
22
+
@@ -0,0 +1,22 @@
1
+ BACKSCRIPT_DATA = [ { :command_name => 'solr_start', :command => "cd #{Rails.root} && bundle exec rake sunspot:solr:start", :type_of_command => 'solr', :active => 'true'},
2
+ { :command_name => 'solr_stop', :command => "cd #{Rails.root} && bundle exec rake sunspot:solr:stop", :type_of_command => 'solr', :active => 'true'},
3
+ { :command_name => 'solr_status', :command => "cd #{Rails.root} && ps -ef | grep solr", :type_of_command => 'solr', :active => 'true'},
4
+ { :command_name => 'reindex_solr',:command => "cd #{Rails.root} && bundle exec rake sunspot:solr:reindex",:type_of_command => 'solr',:active => 'true'},
5
+ { :command_name => 'sidekiq_status', :command => "cd #{Rails.root} && ps -ef | grep sidekiq", :type_of_command => 'sidekiq', :active => 'true'},
6
+ { :command_name => 'sidekiq_stop', :command => "cd #{Rails.root} && rake sidekiq:stop", :type_of_command => 'sidekiq', :active => 'true' },
7
+ { :command_name => 'sidekiq_start', :command => "cd #{Rails.root} && rake sidekiq:start", :type_of_command => 'sidekiq', :active => 'true'},
8
+ { :command_name => 'sidekiq_restart', :command => "cd #{Rails.root} && rake sidekiq:restart", :type_of_command => 'sidekiq', :active => 'true' },
9
+ { :command_name => 'warc_start', :command => "cd #{Rails.root} && rake sidekiq:warc_start", :type_of_command => 'warc', :active => 'true' },
10
+ { :command_name => 'warc_stop', :command => "cd #{Rails.root} && rake sidekiq:warc_stop", :type_of_command => 'warc', :active => 'true' },
11
+ { :command_name => 'warc_restart', :command => "cd #{Rails.root} && rake sidekiq:warc_restart", :type_of_command => 'warc', :active => 'true' },
12
+ { :command_name => 'nginx_start', :command => "cd #{Rails.root} && sudo service nginx start", :type_of_command => 'nginx', :active => 'true' },
13
+ { :command_name => 'nginx_stop', :command => "cd #{Rails.root} && sudo service nginx stop", :type_of_command => 'nginx', :active => 'true' },
14
+ { :command_name => 'nginx_status',:command => "cd #{Rails.root} && sudo service nginx status",:type_of_command => 'nginx', :active => 'true' },
15
+ { :command_name => 'redis_start', :command => "cd #{Rails.root} && sudo service redis_6379 start", :type_of_command => 'redis', :active => 'true' },
16
+ { :command_name => 'redis_stop', :command => "cd #{Rails.root} && sudo service redis_6379 stop", :type_of_command => 'redis', :active => 'true' } ,
17
+ { :command_name => 'redis_status', :command => "cd #{Rails.root} && ps -ef | grep redis", :type_of_command => 'redis', :active => 'true' } ]
18
+
19
+ BACKSCRIPT_DATA.each do |backscript_params|
20
+ Backscript.create!(backscript_params)
21
+ end
22
+
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: back_scrape_job
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Siva subramanian
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-09-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: creating file using generators.
42
+ email:
43
+ - Sivasubramanian.Ramachandran@careerbuilder.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - lib/back_scrape_job.rb
49
+ - lib/back_scrape_job/version.rb
50
+ - lib/generators/initializer/USAGE
51
+ - lib/generators/initializer/initializer_generator.rb
52
+ - lib/generators/initializer/initializer_generator.rb~
53
+ - lib/generators/initializer/templates/backscript.rb
54
+ - lib/generators/initializer/templates/backscript.rb~
55
+ - lib/generators/initializer/templates/backscript_controller.rb
56
+ - lib/generators/initializer/templates/backscript_controller.rb~
57
+ - lib/generators/initializer/templates/backscripts/index.html.erb
58
+ - lib/generators/initializer/templates/backscripts/index.html.erb~
59
+ - lib/generators/initializer/templates/migration.rb
60
+ - lib/generators/initializer/templates/migration.rb~
61
+ - lib/generators/initializer/templates/seed.rb
62
+ - lib/generators/initializer/templates/seed.rb~
63
+ homepage: ''
64
+ licenses:
65
+ - MIT
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 2.4.8
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: creating file in controller model and etc
87
+ test_files: []