itamae-plugin-resource-daemontools_service 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/README.md +7 -3
- data/examples/daemontools_service.rb +65 -65
- data/examples/files/tmp/service/{test → with_log}/env/.gitkeep +0 -0
- data/examples/files/tmp/service/{test → with_log}/log/run +0 -0
- data/examples/files/tmp/service/{test → with_log}/run +0 -0
- data/examples/files/tmp/service/without_log/env/.gitkeep +0 -0
- data/examples/files/tmp/service/without_log/run +7 -0
- data/itamae-plugin-resource-daemontools_service.gemspec +1 -1
- data/lib/itamae/plugin/resource/daemontools_service.rb +14 -24
- data/test.sh +1 -1
- metadata +7 -5
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 6e45984ee2b35354f357ed041f68754b18a5af4e
         | 
| 4 | 
            +
              data.tar.gz: 7721e4b5c2a26c21ab0f11f279729739eec17dc0
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 1140cf4e83596b0ad53939fd23d0d497fb5588e70b272cddb6937823628d55ec49f5397f4e786c523483486d39420195344a47e2a348a2dba2cb64797bb85038
         | 
| 7 | 
            +
              data.tar.gz: f9fe3613689220f5790037473882af505774636934763d40ca75e8f48516aad64d5b48385be1150b27aae1ba1b57a589de8dca3de18083bf2f8d73cbbfa03718
         | 
    
        data/README.md
    CHANGED
    
    | @@ -33,10 +33,14 @@ end | |
| 33 33 |  | 
| 34 34 | 
             
            Options:
         | 
| 35 35 |  | 
| 36 | 
            -
            - service_dir (optional)
         | 
| 37 | 
            -
                - directory that svscan monitors. default is `/service`
         | 
| 38 36 | 
             
            - directory (required)
         | 
| 39 | 
            -
                - directory contains `run` file.  | 
| 37 | 
            +
                - directory contains `run` file. This directory is symlinked. 
         | 
| 38 | 
            +
            - service_dir (option)
         | 
| 39 | 
            +
                - directory that svscan monitors. default is `/service`
         | 
| 40 | 
            +
            - svc_command (option)
         | 
| 41 | 
            +
                - the path of the svc command. default is `svc`
         | 
| 42 | 
            +
            - svstat_command (option)
         | 
| 43 | 
            +
                - the path of the svstat command. default is `svstat`
         | 
| 40 44 |  | 
| 41 45 | 
             
            ## Acknowledgement
         | 
| 42 46 |  | 
| @@ -16,71 +16,71 @@ execute "start svscan" do | |
| 16 16 | 
             
              not_if "initctl status svscan | grep running"
         | 
| 17 17 | 
             
            end
         | 
| 18 18 |  | 
| 19 | 
            -
            # sync test scripts
         | 
| 20 19 | 
             
            directory "/tmp/service"
         | 
| 21 20 |  | 
| 22 | 
            -
             | 
| 23 | 
            -
               | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
            daemontools_service " | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
            end
         | 
| 32 | 
            -
             | 
| 33 | 
            -
            daemontools_service " | 
| 34 | 
            -
             | 
| 35 | 
            -
             | 
| 36 | 
            -
            end
         | 
| 37 | 
            -
             | 
| 38 | 
            -
            daemontools_service " | 
| 39 | 
            -
             | 
| 40 | 
            -
             | 
| 41 | 
            -
            end
         | 
| 42 | 
            -
             | 
| 43 | 
            -
            daemontools_service " | 
| 44 | 
            -
             | 
| 45 | 
            -
             | 
| 46 | 
            -
            end
         | 
| 47 | 
            -
             | 
| 48 | 
            -
            daemontools_service " | 
| 49 | 
            -
             | 
| 50 | 
            -
             | 
| 51 | 
            -
            end
         | 
| 52 | 
            -
             | 
| 53 | 
            -
            daemontools_service " | 
| 54 | 
            -
             | 
| 55 | 
            -
             | 
| 56 | 
            -
            end
         | 
| 57 | 
            -
             | 
| 58 | 
            -
            daemontools_service " | 
| 59 | 
            -
             | 
| 60 | 
            -
             | 
| 61 | 
            -
            end
         | 
| 62 | 
            -
             | 
| 63 | 
            -
            daemontools_service " | 
| 64 | 
            -
             | 
| 65 | 
            -
             | 
| 66 | 
            -
            end
         | 
| 67 | 
            -
             | 
| 68 | 
            -
            daemontools_service " | 
| 69 | 
            -
             | 
| 70 | 
            -
             | 
| 71 | 
            -
            end
         | 
| 72 | 
            -
             | 
| 73 | 
            -
            daemontools_service " | 
| 74 | 
            -
             | 
| 75 | 
            -
             | 
| 76 | 
            -
            end
         | 
| 77 | 
            -
             | 
| 78 | 
            -
            daemontools_service " | 
| 79 | 
            -
             | 
| 80 | 
            -
             | 
| 81 | 
            -
            end
         | 
| 82 | 
            -
             | 
| 83 | 
            -
            daemontools_service " | 
| 84 | 
            -
             | 
| 85 | 
            -
             | 
| 21 | 
            +
            %w[with_log without_log].each do |_service|
         | 
| 22 | 
            +
              # sync test scripts
         | 
| 23 | 
            +
              remote_directory "/tmp/service/#{_service}/" do
         | 
| 24 | 
            +
                source "files/tmp/service/#{_service}/"
         | 
| 25 | 
            +
              end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
              daemontools_service "#{_service}" do
         | 
| 28 | 
            +
                directory "/tmp/service/#{_service}"
         | 
| 29 | 
            +
                action [:enable]
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
              daemontools_service "#{_service}" do
         | 
| 33 | 
            +
                directory "/tmp/service/#{_service}"
         | 
| 34 | 
            +
                action [:enable]
         | 
| 35 | 
            +
              end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
              daemontools_service "#{_service}" do
         | 
| 38 | 
            +
                directory "/tmp/service/#{_service}"
         | 
| 39 | 
            +
                action [:start]
         | 
| 40 | 
            +
              end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
              daemontools_service "#{_service}" do
         | 
| 43 | 
            +
                directory "/tmp/service/#{_service}"
         | 
| 44 | 
            +
                action [:start]
         | 
| 45 | 
            +
              end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
              daemontools_service "#{_service}" do
         | 
| 48 | 
            +
                directory "/tmp/service/#{_service}"
         | 
| 49 | 
            +
                action [:reload]
         | 
| 50 | 
            +
              end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
              daemontools_service "#{_service}" do
         | 
| 53 | 
            +
                directory "/tmp/service/#{_service}"
         | 
| 54 | 
            +
                action [:reload]
         | 
| 55 | 
            +
              end
         | 
| 56 | 
            +
             | 
| 57 | 
            +
              daemontools_service "#{_service}" do
         | 
| 58 | 
            +
                directory "/tmp/service/#{_service}"
         | 
| 59 | 
            +
                action [:stop]
         | 
| 60 | 
            +
              end
         | 
| 61 | 
            +
             | 
| 62 | 
            +
              daemontools_service "#{_service}" do
         | 
| 63 | 
            +
                directory "/tmp/service/#{_service}"
         | 
| 64 | 
            +
                action [:stop]
         | 
| 65 | 
            +
              end
         | 
| 66 | 
            +
             | 
| 67 | 
            +
              daemontools_service "#{_service}" do
         | 
| 68 | 
            +
                directory "/tmp/service/#{_service}"
         | 
| 69 | 
            +
                action [:restart]
         | 
| 70 | 
            +
              end
         | 
| 71 | 
            +
             | 
| 72 | 
            +
              daemontools_service "#{_service}" do
         | 
| 73 | 
            +
                directory "/tmp/service/#{_service}"
         | 
| 74 | 
            +
                action [:restart]
         | 
| 75 | 
            +
              end
         | 
| 76 | 
            +
             | 
| 77 | 
            +
              daemontools_service "#{_service}" do
         | 
| 78 | 
            +
                directory "/tmp/service/#{_service}"
         | 
| 79 | 
            +
                action [:disable]
         | 
| 80 | 
            +
              end
         | 
| 81 | 
            +
             | 
| 82 | 
            +
              daemontools_service "#{_service}" do
         | 
| 83 | 
            +
                directory "/tmp/service/#{_service}"
         | 
| 84 | 
            +
                action [:disable]
         | 
| 85 | 
            +
              end
         | 
| 86 86 | 
             
            end
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| @@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) | |
| 4 4 |  | 
| 5 5 | 
             
            Gem::Specification.new do |spec|
         | 
| 6 6 | 
             
              spec.name          = "itamae-plugin-resource-daemontools_service"
         | 
| 7 | 
            -
              spec.version       = "0.0. | 
| 7 | 
            +
              spec.version       = "0.0.2"
         | 
| 8 8 | 
             
              spec.authors       = ["Naotoshi Seo"]
         | 
| 9 9 | 
             
              spec.email         = ["sonots@gmail.com"]
         | 
| 10 10 | 
             
              spec.summary       = %q{Itamae resource plugin to manage daemontools service.}
         | 
| @@ -7,10 +7,10 @@ module Itamae | |
| 7 7 | 
             
                    define_attribute :action, default: :nothing
         | 
| 8 8 | 
             
                    define_attribute :name, type: String, default_name: true
         | 
| 9 9 |  | 
| 10 | 
            -
                    define_attribute :service_directory, type: String, default: '/service'
         | 
| 11 10 | 
             
                    define_attribute :directory, type: String
         | 
| 12 | 
            -
                    define_attribute : | 
| 13 | 
            -
                    define_attribute : | 
| 11 | 
            +
                    define_attribute :service_dir, type: String, default: '/service'
         | 
| 12 | 
            +
                    define_attribute :svc_command, type: String, default: 'svc'
         | 
| 13 | 
            +
                    define_attribute :svstat_command, type: String, default: 'svstat'
         | 
| 14 14 |  | 
| 15 15 | 
             
                    def initialize(*args)
         | 
| 16 16 | 
             
                      super
         | 
| @@ -25,11 +25,11 @@ module Itamae | |
| 25 25 | 
             
                    end
         | 
| 26 26 |  | 
| 27 27 | 
             
                    def service_name
         | 
| 28 | 
            -
                      shell_escape( | 
| 28 | 
            +
                      shell_escape(attributes.name)
         | 
| 29 29 | 
             
                    end
         | 
| 30 30 |  | 
| 31 31 | 
             
                    def service_link
         | 
| 32 | 
            -
                      "#{shell_escape(attributes. | 
| 32 | 
            +
                      "#{shell_escape(attributes.service_dir)}/#{service_name}"
         | 
| 33 33 | 
             
                    end
         | 
| 34 34 |  | 
| 35 35 | 
             
                    def pre_action
         | 
| @@ -52,63 +52,53 @@ module Itamae | |
| 52 52 |  | 
| 53 53 | 
             
                    def action_start(options)
         | 
| 54 54 | 
             
                      if current.enabled && !current.running
         | 
| 55 | 
            -
                        run_command(" | 
| 55 | 
            +
                        run_command("#{svc_command} -u #{service_link}")
         | 
| 56 56 | 
             
                      end
         | 
| 57 57 | 
             
                    end
         | 
| 58 58 |  | 
| 59 59 | 
             
                    def action_stop(options)
         | 
| 60 60 | 
             
                      if current.enabled && current.running
         | 
| 61 | 
            -
                        run_command(" | 
| 61 | 
            +
                        run_command("#{svc_command} -d #{service_link}")
         | 
| 62 62 | 
             
                      end
         | 
| 63 63 | 
             
                    end
         | 
| 64 64 |  | 
| 65 65 | 
             
                    def action_restart(options)
         | 
| 66 66 | 
             
                      if current.enabled && current.running
         | 
| 67 | 
            -
                        run_command(" | 
| 67 | 
            +
                        run_command("#{svc_command} -t #{service_link}")
         | 
| 68 68 | 
             
                      end
         | 
| 69 69 | 
             
                    end
         | 
| 70 70 |  | 
| 71 71 | 
             
                    def action_reload(options)
         | 
| 72 72 | 
             
                      if current.enabled && current.running
         | 
| 73 | 
            -
                        run_command(" | 
| 73 | 
            +
                        run_command("#{svc_command} -h #{service_link}")
         | 
| 74 74 | 
             
                      end
         | 
| 75 75 | 
             
                    end
         | 
| 76 76 |  | 
| 77 77 | 
             
                    def action_enable(options)
         | 
| 78 78 | 
             
                      if !current.enabled
         | 
| 79 | 
            -
                         | 
| 80 | 
            -
                        run_command("sudo ln -sf #{attributes.directory} #{shell_escape(attributes.service_directory)}/")
         | 
| 79 | 
            +
                        run_command("ln -snf #{attributes.directory} #{service_link}")
         | 
| 81 80 | 
             
                      end
         | 
| 82 81 | 
             
                    end
         | 
| 83 82 |  | 
| 84 83 | 
             
                    def action_disable(options)
         | 
| 85 84 | 
             
                      if current.enabled
         | 
| 86 | 
            -
                         | 
| 87 | 
            -
                        command = <<-"EOF"
         | 
| 88 | 
            -
                          sudo mv #{service_link} #{service_dot_link}
         | 
| 89 | 
            -
                          sudo #{svc_command} -dx #{service_dot_link}
         | 
| 90 | 
            -
                          if [ -d #{service_dot_link}/log ]; then
         | 
| 91 | 
            -
                            sudo #{svc_command} -dx #{service_dot_link}/log
         | 
| 92 | 
            -
                          fi
         | 
| 93 | 
            -
                          sudo rm -f #{service_dot_link}
         | 
| 94 | 
            -
                        EOF
         | 
| 95 | 
            -
                        run_command(command)
         | 
| 85 | 
            +
                        run_command("( cd #{service_link} && rm -f #{service_link} && svc -dx . log )")
         | 
| 96 86 | 
             
                      end
         | 
| 97 87 | 
             
                    end
         | 
| 98 88 |  | 
| 99 | 
            -
                     | 
| 89 | 
            +
                    private
         | 
| 100 90 |  | 
| 101 91 | 
             
                    def service_status!
         | 
| 102 92 | 
             
                      if run_command("test -L #{service_link} && test -f #{service_link}/run", error: false).exit_status == 0
         | 
| 103 93 | 
             
                        current.enabled = true
         | 
| 104 | 
            -
                        result = run_command(" | 
| 94 | 
            +
                        result = run_command("#{svstat_command} #{service_link}", error: false)
         | 
| 105 95 | 
             
                        if result.exit_status == 0
         | 
| 106 96 |  | 
| 107 97 | 
             
                          retry_count = 4
         | 
| 108 98 | 
             
                          while result.stdout =~ /: supervise not running/ or result.stdout =~ /: unable to open supervise\/ok/
         | 
| 109 99 | 
             
                            sleep 1
         | 
| 110 100 | 
             
                            retry_count -= 1
         | 
| 111 | 
            -
                            result = run_command(" | 
| 101 | 
            +
                            result = run_command("#{svstat_command} #{service_link}", error: false)
         | 
| 112 102 | 
             
                            break if retry_count < 0
         | 
| 113 103 | 
             
                          end
         | 
| 114 104 |  | 
    
        data/test.sh
    CHANGED
    
    | @@ -1,2 +1,2 @@ | |
| 1 1 | 
             
            #!/bin/bash
         | 
| 2 | 
            -
            bundle exec itamae ssh --vagrant -h vagrant-centos examples/daemontools_service.rb
         | 
| 2 | 
            +
            bundle exec itamae ssh -l debug --vagrant -h vagrant-centos examples/daemontools_service.rb
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: itamae-plugin-resource-daemontools_service
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Naotoshi Seo
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2015-05- | 
| 11 | 
            +
            date: 2015-05-20 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         | 
| @@ -82,9 +82,11 @@ files: | |
| 82 82 | 
             
            - Vagrantfile
         | 
| 83 83 | 
             
            - examples/daemontools_service.rb
         | 
| 84 84 | 
             
            - examples/files/etc/init/svscan.conf
         | 
| 85 | 
            -
            - examples/files/tmp/service/ | 
| 86 | 
            -
            - examples/files/tmp/service/ | 
| 87 | 
            -
            - examples/files/tmp/service/ | 
| 85 | 
            +
            - examples/files/tmp/service/with_log/env/.gitkeep
         | 
| 86 | 
            +
            - examples/files/tmp/service/with_log/log/run
         | 
| 87 | 
            +
            - examples/files/tmp/service/with_log/run
         | 
| 88 | 
            +
            - examples/files/tmp/service/without_log/env/.gitkeep
         | 
| 89 | 
            +
            - examples/files/tmp/service/without_log/run
         | 
| 88 90 | 
             
            - itamae-plugin-resource-daemontools_service.gemspec
         | 
| 89 91 | 
             
            - lib/itamae/plugin/resource/daemontools_service.rb
         | 
| 90 92 | 
             
            - spec/itamae/plugin/resource/daemontools_service_spec.rb
         |