avm-tools 0.115.0 → 0.116.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (23) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/tools/version.rb +1 -1
  3. data/sub/avm-eac_rails_base0/avm-eac_rails_base0.gemspec +1 -1
  4. data/sub/avm-eac_rails_base0/lib/avm/eac_rails_base0/version.rb +1 -1
  5. data/sub/avm-eac_rails_base1/avm-eac_rails_base1.gemspec +1 -1
  6. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner/tasks_scheduler/systemd_unit.rb +46 -0
  7. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner/tasks_scheduler.rb +17 -0
  8. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/systemd_unit/service.rb +70 -0
  9. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/systemd_unit/tasks_scheduler_command.rb +29 -0
  10. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/systemd_unit.rb +57 -0
  11. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/version.rb +1 -1
  12. data/sub/avm-eac_rails_base1/template/avm/eac_rails_base1/systemd_unit/tasks_scheduler.service +12 -0
  13. data/sub/avm-eac_rails_base1/template/avm/eac_rails_base1/systemd_unit/tasks_scheduler_command.sh +6 -0
  14. data/sub/avm-eac_redmine_base0/avm-eac_redmine_base0.gemspec +1 -1
  15. data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/version.rb +1 -1
  16. data/sub/avm-eac_ubuntu_base0/lib/avm/eac_ubuntu_base0/instances/base.rb +6 -0
  17. data/sub/avm-eac_ubuntu_base0/lib/avm/eac_ubuntu_base0/version.rb +1 -1
  18. data/sub/avm-eac_webapp_base0/avm-eac_webapp_base0.gemspec +1 -1
  19. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instance.rb +7 -0
  20. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/version.rb +1 -1
  21. data/sub/eac_cli/lib/eac_cli/runner_with/subcommands.rb +1 -1
  22. data/sub/eac_cli/lib/eac_cli/version.rb +1 -1
  23. metadata +17 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf0d93631b14929c6e271ba0dd835f75a9633a961b3f870daa5c64eb467e0ef2
4
- data.tar.gz: '0281c164c78506d7fe5ac8f601ce4380661f835a3c4e0ebe7c48c60334419565'
3
+ metadata.gz: 27716dd4266fe2074f32cc46de1d3d4b0a83612a50e4794f9948523d3ed6bad5
4
+ data.tar.gz: 97d712f91c0adbeacedd67674ae108d9f48fd2db800df50696625a7d81bd95f3
5
5
  SHA512:
6
- metadata.gz: bcbb490835a6f843cb9179effd073b661e7d4c7d1006ae4a135744d692203425ab8c4f9dbd18d55af1b1744655ec216c3feaf23470c1df691788eb3d94030a9d
7
- data.tar.gz: 2e647b2157fe2c3bdf9ea51ebaac0809e4299af1bb13c96b73bae51c68e9876ba37347a9a85f3e15b8eede0c837546edf05079b116abf67081ecbe28062092b3
6
+ metadata.gz: ba1854580f3fd1cbda82b94422e8feffde990f8f8ec4ec5e789f7e565536502f581a9e6da694a2eb04c76da27916b6bbd8504dc6663e8a540aae7e8517941256
7
+ data.tar.gz: fc5000e7db1db0c41cda3768665ce4bd08846a81ba7c7f8d5b8c8e014d79fc28bf99a6d0fa5ba75d7b2d8b3be360c2dd13d18321cdb0b1789972f84e89616d60
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.115.0'
5
+ VERSION = '0.116.0'
6
6
  end
7
7
  end
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.files = Dir['{lib,template}/**/*']
14
14
 
15
- s.add_dependency 'avm-eac_rails_base1', '~> 0.1', '>= 0.1.3'
15
+ s.add_dependency 'avm-eac_rails_base1', '~> 0.2'
16
16
  s.add_dependency 'eac_ruby_utils', '~> 0.80', '>= 0.80.2'
17
17
 
18
18
  s.add_development_dependency 'eac_ruby_gem_support', '~> 0.4'
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module EacRailsBase0
5
- VERSION = '0.2.0'
5
+ VERSION = '0.3.0'
6
6
  end
7
7
  end
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.files = Dir['{lib}/**/*']
14
14
 
15
- s.add_dependency 'avm-eac_webapp_base0', '~> 0.2', '>= 0.2.1'
15
+ s.add_dependency 'avm-eac_webapp_base0', '~> 0.3'
16
16
  s.add_dependency 'eac_ruby_gems_utils', '~> 0.9', '>= 0.9.9'
17
17
  s.add_dependency 'eac_ruby_utils', '~> 0.68'
18
18
 
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_rails_base1/systemd_unit'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module EacRailsBase1
8
+ class Runner < ::Avm::EacWebappBase0::Runner
9
+ class TasksScheduler
10
+ class SystemdUnit
11
+ DEFAULT_RESTART = 'on-failure'
12
+
13
+ runner_with :help do
14
+ desc 'Configure Systemd unit for instace\'s tasks scheduler daemon (Reference: ' \
15
+ 'https://www.freedesktop.org/software/systemd/man/systemd.service.html).'
16
+ bool_opt '-e', '--exec-run', 'Run daemon with "run" instead of "start"/"stop".'
17
+ arg_opt '-r', '--restart', 'Value for systemd.service, Restart=.',
18
+ default: DEFAULT_RESTART
19
+ end
20
+
21
+ delegate :restart, to: :parsed
22
+
23
+ def run
24
+ if result.error?
25
+ fatal_error result.to_s
26
+ else
27
+ infov 'Result', result.label
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def systemd_unit_uncached
34
+ ::Avm::EacRailsBase1::SystemdUnit.new(runner_context.call(:instance),
35
+ restart: parsed.restart,
36
+ exec_run: parsed.exec_run?)
37
+ end
38
+
39
+ def result_uncached
40
+ systemd_unit.run
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module EacRailsBase1
7
+ class Runner < ::Avm::EacWebappBase0::Runner
8
+ class TasksScheduler
9
+ require_sub __FILE__
10
+
11
+ runner_with :help, :subcommands do
12
+ subcommands
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module EacRailsBase1
7
+ class SystemdUnit
8
+ module Service
9
+ def service_content
10
+ template.child('tasks_scheduler.service').apply(variables_source)
11
+ end
12
+
13
+ def service_exec_lines
14
+ service_exec_operations
15
+ .map { |k, v| "#{k}=#{tasks_scheduler_command_path} #{v}" }
16
+ .join("\n")
17
+ end
18
+
19
+ def service_path
20
+ ::Pathname.new('/etc/systemd/system').join(unit_name)
21
+ end
22
+
23
+ def service_link_path
24
+ ::Pathname.new('/etc/systemd/system/multi-user.target.wants').join(unit_name)
25
+ end
26
+
27
+ def verify_service
28
+ sudo_system!('systemd-analyze', 'verify', service_path)
29
+ end
30
+
31
+ private
32
+
33
+ def enable_service
34
+ systemctl('enable', unit_name)
35
+ end
36
+
37
+ def link_service
38
+ sudo_execute!('rm', '-f', service_link_path)
39
+ sudo_execute!('ln', '-s', service_path, service_link_path)
40
+ end
41
+
42
+ def reload_systemd
43
+ systemctl('daemon-reload')
44
+ end
45
+
46
+ # @return [Hash<String, String>]
47
+ def service_exec_operations
48
+ if exec_run?
49
+ { 'ExecStart' => 'run' }
50
+ else
51
+ { 'ExecStart' => 'start', 'ExecStop' => 'stop' }
52
+ end
53
+ end
54
+
55
+ def start_service
56
+ systemctl('start', unit_name)
57
+ end
58
+
59
+ def systemctl(*args)
60
+ sudo_system!('systemctl', *args)
61
+ end
62
+
63
+ def write_service
64
+ infom 'Writing service\'s unit file...'
65
+ platform_instance.file_sudo_write(service_path, service_content)
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module EacRailsBase1
7
+ class SystemdUnit
8
+ module TasksSchedulerCommand
9
+ def tasks_scheduler_command_content
10
+ template.child('tasks_scheduler_command.sh').apply(variables_source)
11
+ end
12
+
13
+ def tasks_scheduler_command_path
14
+ "/opt/aux/#{instance.id}/tasks_scheduler.sh"
15
+ end
16
+
17
+ private
18
+
19
+ def write_tasks_scheduler_command
20
+ infom 'Writing tasks scheduler\'s command...'
21
+ sudo_execute!('mkdir', '-p', ::File.dirname(tasks_scheduler_command_path))
22
+ platform_instance.file_sudo_write(tasks_scheduler_command_path,
23
+ tasks_scheduler_command_content)
24
+ sudo_execute!('chmod', '+x', tasks_scheduler_command_path)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/jobs/base'
4
+ require 'avm/eac_ubuntu_base0/apache'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module Avm
8
+ module EacRailsBase1
9
+ class SystemdUnit
10
+ JOBS = %w[write_tasks_scheduler_command write_service link_service verify_service
11
+ reload_systemd enable_service start_service].freeze
12
+
13
+ include ::Avm::Jobs::Base
14
+ require_sub __FILE__, include_modules: true
15
+ delegate :platform_instance, to: :instance
16
+
17
+ enable_listable
18
+ lists.add_symbol :option, :exec_run, :restart
19
+
20
+ def description
21
+ "#{instance.id} Tasks Scheduler"
22
+ end
23
+
24
+ def exec_run?
25
+ options[OPTION_EXEC_RUN]
26
+ end
27
+
28
+ def option_list
29
+ self.class.lists.option
30
+ end
31
+
32
+ def restart
33
+ options[OPTION_RESTART]
34
+ end
35
+
36
+ def unit_name
37
+ "#{instance.id}_tasks_scheduler.service"
38
+ end
39
+
40
+ def user
41
+ instance.ssh_username
42
+ end
43
+
44
+ private
45
+
46
+ def sudo_execute!(*args)
47
+ platform_instance.host_env.command(['sudo'] + args).execute!
48
+ end
49
+
50
+ def sudo_system!(*args)
51
+ command_args = ['sudo'] + args
52
+ infom "Running \"#{::Shellwords.join(command_args)}\"..."
53
+ platform_instance.host_env.command(command_args).system!
54
+ end
55
+ end
56
+ end
57
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module EacRailsBase1
5
- VERSION = '0.1.4'
5
+ VERSION = '0.2.0'
6
6
  end
7
7
  end
@@ -0,0 +1,12 @@
1
+ [Unit]
2
+ Description='%%description%%'
3
+ After=postgresql.service
4
+
5
+ [Service]
6
+ Type=forking
7
+ %%service_exec_lines%%
8
+ Restart=%%restart%%
9
+ User=%%user%%
10
+
11
+ [Install]
12
+ WantedBy=multi-user.target
@@ -0,0 +1,6 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+
5
+ source "$HOME/.rvm/scripts/rvm"
6
+ ( cd '%%fs_path%%'; bundle exec tasks_scheduler "$@" )
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.files = Dir['{lib,template}/**/*']
14
14
 
15
- s.add_dependency 'avm-eac_rails_base1', '~> 0.1'
15
+ s.add_dependency 'avm-eac_rails_base1', '~> 0.2'
16
16
  s.add_dependency 'avm-eac_ubuntu_base0', '~> 0.2'
17
17
  s.add_dependency 'curb', '~> 0.9.10'
18
18
  s.add_dependency 'eac_fs', '~> 0.4'
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module EacRedmineBase0
5
- VERSION = '0.4.1'
5
+ VERSION = '0.5.0'
6
6
  end
7
7
  end
@@ -10,6 +10,12 @@ module Avm
10
10
  def docker_image_class
11
11
  ::Avm::EacUbuntuBase0::DockerImage
12
12
  end
13
+
14
+ def file_sudo_write(path, content)
15
+ ::EacRubyUtils::Envs.local.command('echo', content).pipe(
16
+ host_env.command('sudo', 'tee', path)
17
+ ).execute!
18
+ end
13
19
  end
14
20
  end
15
21
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module EacUbuntuBase0
5
- VERSION = '0.2.1'
5
+ VERSION = '0.3.0'
6
6
  end
7
7
  end
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.add_dependency 'avm', '~> 0.1'
16
16
  s.add_dependency 'avm-eac_generic_base0', '~> 0.1'
17
17
  s.add_dependency 'avm-eac_postgresql_base0', '~> 0.1'
18
- s.add_dependency 'avm-eac_ubuntu_base0', '~> 0.2.1'
18
+ s.add_dependency 'avm-eac_ubuntu_base0', '~> 0.3'
19
19
  s.add_dependency 'eac_ruby_utils', '~> 0.68'
20
20
 
21
21
  s.add_development_dependency 'eac_ruby_gem_support', '~> 0.2'
@@ -5,12 +5,14 @@ require 'avm/eac_postgresql_base0/instance_with'
5
5
  require 'avm/data/instance/files_unit'
6
6
  require 'avm/data/instance/package'
7
7
  require 'avm/eac_webapp_base0/deploy/file_unit'
8
+ require 'avm/eac_ubuntu_base0/instances/base'
8
9
 
9
10
  module Avm
10
11
  module EacWebappBase0
11
12
  class Instance < ::Avm::Instances::Base
12
13
  require_sub __FILE__
13
14
  include ::Avm::EacPostgresqlBase0::InstanceWith
15
+ enable_simple_cache
14
16
 
15
17
  FILES_UNITS = [].freeze
16
18
 
@@ -45,6 +47,11 @@ module Avm
45
47
 
46
48
  private
47
49
 
50
+ # @return [Avm::EacUbuntuBase0::Instances::Base]
51
+ def platform_instance_uncached
52
+ ::Avm::EacUbuntuBase0::Instances::Base.by_id(id)
53
+ end
54
+
48
55
  def files_units
49
56
  self.class.const_get('FILES_UNITS').transform_values do |fs_path_subpath|
50
57
  ::Avm::Data::Instance::FilesUnit.new(self, fs_path_subpath)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module EacWebappBase0
5
- VERSION = '0.2.1'
5
+ VERSION = '0.3.0'
6
6
  end
7
7
  end
@@ -95,7 +95,7 @@ module EacCli
95
95
  raise(::EacCli::Parser::Error.new(
96
96
  self.class.runner_definition, runner_context.argv,
97
97
  "Subcommand \"#{subcommand_name}\" not found " \
98
- "(Available: #{available_subcommands.keys}"
98
+ "(Available: #{available_subcommands.keys})"
99
99
  ))
100
100
  end
101
101
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacCli
4
- VERSION = '0.27.1'
4
+ VERSION = '0.27.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.115.0
4
+ version: 0.116.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-04-04 00:00:00.000000000 Z
11
+ date: 2022-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -58,56 +58,56 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0.2'
61
+ version: '0.3'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0.2'
68
+ version: '0.3'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: avm-eac_redmine_base0
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0.4'
75
+ version: '0.5'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0.4'
82
+ version: '0.5'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: avm-eac_ruby_base1
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0.1'
89
+ version: '0.2'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0.1'
96
+ version: '0.2'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: avm-eac_ubuntu_base0
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0.2'
103
+ version: '0.3'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '0.2'
110
+ version: '0.3'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: avm-files
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -497,11 +497,18 @@ files:
497
497
  - sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner/logs.rb
498
498
  - sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner/logs/clear.rb
499
499
  - sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner/rails_server.rb
500
+ - sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner/tasks_scheduler.rb
501
+ - sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner/tasks_scheduler/systemd_unit.rb
500
502
  - sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner_with/bundle.rb
501
503
  - sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner_with/rails_environment.rb
504
+ - sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/systemd_unit.rb
505
+ - sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/systemd_unit/service.rb
506
+ - sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/systemd_unit/tasks_scheduler_command.rb
502
507
  - sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/version.rb
503
508
  - sub/avm-eac_rails_base1/spec/rubocop_spec.rb
504
509
  - sub/avm-eac_rails_base1/spec/spec_helper.rb
510
+ - sub/avm-eac_rails_base1/template/avm/eac_rails_base1/systemd_unit/tasks_scheduler.service
511
+ - sub/avm-eac_rails_base1/template/avm/eac_rails_base1/systemd_unit/tasks_scheduler_command.sh
505
512
  - sub/avm-eac_redmine_base0/Gemfile
506
513
  - sub/avm-eac_redmine_base0/avm-eac_redmine_base0.gemspec
507
514
  - sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0.rb