-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcall-reign-async
executable file
·41 lines (31 loc) · 1.36 KB
/
call-reign-async
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/sh
. lib/shable
include "base"
_reign="${1}"
if [ -z "${_reign}" ]; then
error "No arguments given, with reign names to invoke!"
fi
debug "Reign to be invoked: $(distd "${_reign}")"
_inv="${2:-${DEFAULT_INVENTORY}}"
if [ "Darwin" = "${SYSTEM_NAME}" ]; then
_cmd="sudo -H RUN_AS=root bin/shable inventory setup-macos-limits"
_current_openfiles_max="$(launchctl limit maxfiles | ${AWK_BIN} '{print $2;}' 2>/dev/null)"
if [ "256" = "${_current_openfiles_max}" ]; then
warn "Shable detected system type: $(distw "Darwin") with default limits set."
warn "If you experience problems with multiple asynchronous SSH connections at once,"
warn "please invoke this on your workstation: $(distw "${_cmd}")."
warn "This will persistently increase default system limits."
fi
fi
_hosts=$(inventory_hosts "${_inv}")
note "Calling reign: $(distn "${_reign}") on hosts: $(distd "$(echo "${_hosts}" | ${TR_BIN} '\n' ' ' 2>/dev/null)")"
unset _process_logs
for _host in ${_hosts}; do
_log="${DEFAULT_LOGDIR}/reign-${_reign}-on-${_host}.log"
_process_logs="${_log} ${_process_logs}"
echo > "${_log}" # Clean previous log
throttle
progress_note "Invoking reign: $(distn "${_reign}") for host: $(distn "${_host}")"
bin/reign "${_inv}" "${_reign}" "${_host}" >> "${_log}" 2>> "${_log}" &
done
await_async "${_process_logs}"