Sha256: 8f1fda3cf43e1fc0a69f650f9bf09a53075fc07dc59340c5554b584531f649f4

Contents?: true

Size: 1.54 KB

Versions: 9

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

9 entries across 9 versions & 1 rubygems

Version Path
nixenvironment-0.0.161 lib/nixenvironment/jenkins/master/master_starter.rb
nixenvironment-0.0.160 lib/nixenvironment/jenkins/master/master_starter.rb
nixenvironment-0.0.159 lib/nixenvironment/jenkins/master/master_starter.rb
nixenvironment-0.0.158 lib/nixenvironment/jenkins/master/master_starter.rb
nixenvironment-0.0.157 lib/nixenvironment/jenkins/master/master_starter.rb
nixenvironment-0.0.156 lib/nixenvironment/jenkins/master/master_starter.rb
nixenvironment-0.0.155 lib/nixenvironment/jenkins/master/master_starter.rb
nixenvironment-0.0.154 lib/nixenvironment/jenkins/master/master_starter.rb
nixenvironment-0.0.153 lib/nixenvironment/jenkins/master/master_starter.rb