Sha256: 60803c8474f3b2423fbd18f6ef801b17bf0bf5f7f5b81100cc04ae301364af02

Contents?: true

Size: 1.54 KB

Versions: 15

Compression:

Stored size: 1.54 KB

Contents

require_relative '../modules/applet_helper'
require_relative '../modules/paths'
require_relative '../modules/exceptions'
require_relative '../modules/git_helper'
require_relative '../modules/provisioning_helper'

class MasterStarter
    include AppletHelper
    include Paths
    include GitHelper
    include ProvisioningHelper

    private
    def kill_proc(name)
        `pids=$(ps -fu $USER | grep "#{name}" | grep -v "grep" | awk '{print $2}'); for pid in ${pids[@]}; do kill -9 $pid; done`
    end

    def add_to_autorun
      `osascript -e 'tell application "System Events" to make login item at end with properties {path:"#{__dir__}/iJenkins_autorun", hidden:true, name:"iJenkins Master"}'`
    end

    public
    def start
        raise NotInitialized unless should_start_slave

        add_to_autorun

        # Applet
        start_master
        
        # Start provisioning updater
        start_pu

        # Git
        hook_thread = set_git_hook do
          remove_local_provisioning_profiles
          copy_jenkins_provisioning_profiles
        end

        hook_thread.join

        true
    end

    def start_pu(on_production = true)
      fork do
        Dir.chdir(path_to_provisioning_updater) do
          if on_production
            `./run -e production -p 3000`
          else
            `./run`
          end
        end
      end
    end

    def stop
        stop_applets
        stop_pu
        kill_proc("rails")
    end

    def stop_pu
      `kill -9 "$(cat #{path_to_provisioning_updater}/tmp/pids/server.pid)" 2>/dev/null`
    end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
nixenvironment-0.0.152 lib/nixenvironment/jenkins/master/master_starter.rb
nixenvironment-0.0.150 lib/nixenvironment/jenkins/master/master_starter.rb
nixenvironment-0.0.148 lib/nixenvironment/jenkins/master/master_starter.rb
nixenvironment-0.0.141 lib/nixenvironment/jenkins/master/master_starter.rb
nixenvironment-0.0.147 lib/nixenvironment/jenkins/master/master_starter.rb
nixenvironment-0.0.146 lib/nixenvironment/jenkins/master/master_starter.rb
nixenvironment-0.0.145 lib/nixenvironment/jenkins/master/master_starter.rb
nixenvironment-0.0.144 lib/nixenvironment/jenkins/master/master_starter.rb
nixenvironment-0.0.143 lib/nixenvironment/jenkins/master/master_starter.rb
nixenvironment-0.0.142 lib/nixenvironment/jenkins/master/master_starter.rb
nixenvironment-0.0.138.1 lib/nixenvironment/jenkins/master/master_starter.rb
nixenvironment-0.0.138 lib/nixenvironment/jenkins/master/master_starter.rb
nixenvironment-0.0.140 lib/nixenvironment/jenkins/master/master_starter.rb
nixenvironment-0.0.139 lib/nixenvironment/jenkins/master/master_starter.rb
nixenvironment-0.0.137 lib/nixenvironment/jenkins/master/master_starter.rb