Skip to content

Commit

Permalink
Improved launcher script (#339)
Browse files Browse the repository at this point in the history
* Improved launcher script

Seems ERL_LIBS wasn't picked up universally across versions, so I
swapped that out for the -pa flag

* silenced errors, used command -v to check for asdf / rtx

* Evalled output from rtx env

* fixed typo

* Update bin/start_lexical.sh

Co-authored-by: Étienne Lévesque <[email protected]>

---------

Co-authored-by: Étienne Lévesque <[email protected]>
  • Loading branch information
scohen and Blond11516 committed Aug 23, 2023
1 parent bac4cc4 commit cb33a1e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions bin/start_lexical.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
#!/usr/bin/env bash

set_up_version_manager() {
if [ -e $HOME/.asdf ] && asdf which elixir > /dev/null -eq 0; then
if command -v asdf > /dev/null && asdf which elixir > /dev/null 2>&1 ; then
VERSION_MANAGER="asdf"
elif [ -e $HOME/.rtx ] && rtx which elixir > /dev/null -eq 0; then
elif command -v rtx > /dev/null && rtx which elixir > /dev/null 2>&1 ; then
VERSION_MANAGER="rtx"
else
VERSION_MANAGER="none"
fi
}


set_up_version_manager

# Start the program in the background
Expand All @@ -19,7 +18,7 @@ case "$VERSION_MANAGER" in
asdf env erl exec "$@" &
;;
rtx)
rtx env -s bash erl exec "$@" &
eval "$(rtx env -s bash)"
;;
*)
;;
Expand All @@ -36,8 +35,14 @@ esac

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

export ERL_LIBS="${SCRIPT_DIR}/../lib"
"${ELIXIR_COMMAND}" -pa "${SCRIPT_DIR}/../consolidated" \
PATH_APPEND_ARGS=$(for f in $(find ${SCRIPT_DIR}/../lib -name '*.ez')
do
lib=$(basename $f | sed -e 's/.ez//g')
echo "-pa $f/$lib/ebin"
done)

"${ELIXIR_COMMAND}" $(echo $PATH_APPEND_ARGS) \
-pa "${SCRIPT_DIR}/../consolidated" \
-pa "${SCRIPT_DIR}/../config/" \
-pa "${SCRIPT_DIR}/../priv/" \
--eval "LXical.Server.Boot.start" \
Expand Down

0 comments on commit cb33a1e

Please sign in to comment.