Fix post installation 'hang' bug, simplify daemon start

pull/184/head
Simon Let 3 years ago
parent cb5e01bd07
commit 4383d2b30a
  1. 6
      Makefile
  2. 7
      scripts/hooks.sh
  3. 16
      scripts/install.sh
  4. 2
      scripts/resh-daemon-start.sh
  5. 8
      scripts/reshctl.sh
  6. 5
      scripts/shellrc.sh
  7. 16
      scripts/util.sh

@ -9,7 +9,12 @@ build: submodules bin/resh-session-init bin/resh-collect bin/resh-postcollect\
bin/resh-daemon bin/resh-control bin/resh-config bin/resh-cli\ bin/resh-daemon bin/resh-control bin/resh-config bin/resh-cli\
bin/resh-install-utils bin/resh-generate-uuid bin/resh-get-epochtime bin/resh-install-utils bin/resh-generate-uuid bin/resh-get-epochtime
# we disable jobserver for the actual installation because we want it to run serially
# Make waits to the daemon process we launch during install and hangs
install: build install: build
make -j1 _install
_install:
scripts/install.sh scripts/install.sh
test: test:
@ -35,7 +40,6 @@ bin/resh-%: $(go_files)
.PHONY: submodules build install rebuild uninstall clean test .PHONY: submodules build install rebuild uninstall clean test
submodules: | submodules/bash-preexec/bash-preexec.sh submodules/bash-zsh-compat-widgets/bindfunc.sh submodules: | submodules/bash-preexec/bash-preexec.sh submodules/bash-zsh-compat-widgets/bindfunc.sh
@# sets submodule.recurse to true if unset @# sets submodule.recurse to true if unset
@# sets status.submoduleSummary to true if unset @# sets status.submoduleSummary to true if unset

@ -37,7 +37,6 @@ __resh_collect() {
echo "RESH WARNING: You probably just updated RESH - PLEASE RESTART OR RELOAD THIS TERMINAL SESSION (resh revision: $(resh-collect -revision); resh revision of this terminal session: ${__RESH_REVISION})" echo "RESH WARNING: You probably just updated RESH - PLEASE RESTART OR RELOAD THIS TERMINAL SESSION (resh revision: $(resh-collect -revision); resh revision of this terminal session: ${__RESH_REVISION})"
fi fi
fi fi
# TODO: change how resh-uuid is read
if [ "$__RESH_VERSION" = "$(resh-collect -version)" ] && [ "$__RESH_REVISION" = "$(resh-collect -revision)" ]; then if [ "$__RESH_VERSION" = "$(resh-collect -version)" ] && [ "$__RESH_REVISION" = "$(resh-collect -revision)" ]; then
resh-collect -requireVersion "$__RESH_VERSION" \ resh-collect -requireVersion "$__RESH_VERSION" \
-requireRevision "$__RESH_REVISION" \ -requireRevision "$__RESH_REVISION" \
@ -51,9 +50,9 @@ __resh_collect() {
-gitRemote "$__RESH_GIT_REMOTE" \ -gitRemote "$__RESH_GIT_REMOTE" \
-time "$__RESH_RT_BEFORE" \ -time "$__RESH_RT_BEFORE" \
"$@" "$@"
return $? return $?
fi fi
return 1 return 1
} }
__resh_precmd() { __resh_precmd() {

@ -109,6 +109,7 @@ cp -f submodules/bash-preexec/bash-preexec.sh ~/.bash-preexec.sh
cp -f submodules/bash-zsh-compat-widgets/bindfunc.sh ~/.resh/bindfunc.sh cp -f submodules/bash-zsh-compat-widgets/bindfunc.sh ~/.resh/bindfunc.sh
cp -f scripts/shellrc.sh ~/.resh/shellrc cp -f scripts/shellrc.sh ~/.resh/shellrc
cp -f scripts/resh-daemon-start.sh ~/.resh/bin/resh-daemon-start
cp -f scripts/reshctl.sh scripts/widgets.sh scripts/hooks.sh scripts/util.sh ~/.resh/ cp -f scripts/reshctl.sh scripts/widgets.sh scripts/hooks.sh scripts/util.sh ~/.resh/
cp -f scripts/rawinstall.sh ~/.resh/ cp -f scripts/rawinstall.sh ~/.resh/
@ -126,11 +127,15 @@ if [ ! -f "$pid_file" ]; then
pid_file=~/.resh/resh.pid pid_file=~/.resh/resh.pid
fi fi
failed_to_kill() {
echo "ERROR: Failed to kill the resh-daemon - maybe it wasn't running?"
}
if [ -f "$pid_file" ]; then if [ -f "$pid_file" ]; then
kill -SIGTERM "$pid_file" kill -SIGKILL "$pid_file" || failed_to_kill
rm "$pid_file" rm "$pid_file"
else else
pkill -SIGTERM "resh-daemon" pkill -SIGKILL "resh-daemon" || failed_to_kill
fi fi
echo "Creating/updating config file ..." echo "Creating/updating config file ..."
@ -161,13 +166,8 @@ fi
# Deleting zsh completion cache - for future use # Deleting zsh completion cache - for future use
# [ ! -e ~/.zcompdump ] || rm ~/.zcompdump # [ ! -e ~/.zcompdump ] || rm ~/.zcompdump
# Source utils to get __resh_run_daemon function
# shellcheck source=util.sh
. ~/.resh/util.sh
echo "Launching resh daemon ..." echo "Launching resh daemon ..."
__resh_run_daemon ~/.resh/bin/resh-daemon-start
info="---- Scroll down using arrow keys ---- info="---- Scroll down using arrow keys ----
##################################### #####################################

@ -0,0 +1,2 @@
#! /usr/bin/env sh
nohup resh-daemon >/dev/null 2>/dev/null & disown

@ -50,14 +50,6 @@ __resh_unbind_control_R() {
return 0 return 0
} }
__resh_bind_all() {
__resh_bind_control_R
}
__resh_unbind_all() {
__resh_unbind_control_R
}
# wrapper for resh-cli for calling resh directly # wrapper for resh-cli for calling resh directly
resh() { resh() {
local buffer local buffer

@ -1,9 +1,6 @@
#!/hint/sh #!/hint/sh
PATH=$PATH:~/.resh/bin PATH=$PATH:~/.resh/bin
# if [ -n "$ZSH_VERSION" ]; then
# zmodload zsh/datetime
# fi
# shellcheck source=hooks.sh # shellcheck source=hooks.sh
. ~/.resh/hooks.sh . ~/.resh/hooks.sh
@ -31,7 +28,7 @@ export __RESH_VERSION=$(resh-collect -version)
# shellcheck disable=2155 # shellcheck disable=2155
export __RESH_REVISION=$(resh-collect -revision) export __RESH_REVISION=$(resh-collect -revision)
__resh_run_daemon resh-daemon-start
[ "$(resh-config --key BindControlR)" = true ] && __resh_bind_control_R [ "$(resh-config --key BindControlR)" = true ] && __resh_bind_control_R

@ -2,22 +2,6 @@
# util.sh - resh utility functions # util.sh - resh utility functions
# FIXME: figure out if stdout/stderr should be discarded
__resh_run_daemon() {
if [ -n "${ZSH_VERSION-}" ]; then
setopt LOCAL_OPTIONS NO_NOTIFY NO_MONITOR
fi
if [ "$(uname)" = Darwin ]; then
# hotfix
gnohup resh-daemon >/dev/null 2>/dev/null & disown
else
# TODO: switch to nohup for consistency once you confirm that daemon is
# not getting killed anymore on macOS
nohup resh-daemon >/dev/null 2>/dev/null & disown
#setsid resh-daemon 2>&1 & disown
fi
}
__resh_session_init() { __resh_session_init() {
if [ "$__RESH_VERSION" != "$(resh-session-init -version)" ]; then if [ "$__RESH_VERSION" != "$(resh-session-init -version)" ]; then
# shellcheck source=shellrc.sh # shellcheck source=shellrc.sh

Loading…
Cancel
Save