Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Improve entry point runner UX #158

Merged
merged 6 commits into from
Nov 30, 2023

Conversation

dmitrii-ubskii
Copy link
Member

@dmitrii-ubskii dmitrii-ubskii commented Nov 29, 2023

What is the goal of this PR?

We provide a single server entry point for starting up both core and enterprise server, whichever happens to be installed. We also omit server or console from the usage help if it is not present to avoid confusion. See vaticle/typedb#6942 for more details.

We also improve the UX of the windows version of the entry point. Console no longer opens in a new window, --help is printed inline as expected, and in the event of the server failure, the logs are displayed to the user.

@vaticle-bot
Copy link
Member

vaticle-bot commented Nov 29, 2023

PR Review Checklist

Do not edit the content of this comment. The PR reviewer should simply update this comment by ticking each review item below, as they get completed.


Trivial Change

  • This change is trivial and does not require a code or architecture review.

Code

  • Packages, classes, and methods have a single domain of responsibility.
  • Packages, classes, and methods are grouped into cohesive and consistent domain model.
  • The code is canonical and the minimum required to achieve the goal.
  • Modules, libraries, and APIs are easy to use, robust (foolproof and not errorprone), and tested.
  • Logic and naming has clear narrative that communicates the accurate intent and responsibility of each module (e.g. method, class, etc.).
  • The code is algorithmically efficient and scalable for the whole application.

Architecture

  • Any required refactoring is completed, and the architecture does not introduce technical debt incidentally.
  • Any required build and release automations are updated and/or implemented.
  • Any new components follows a consistent style with respect to the pre-existing codebase.
  • The architecture intuitively reflects the application domain, and is easy to understand.
  • The architecture has a well-defined hierarchy of encapsulated components.
  • The architecture is extensible and scalable.

binary/typedb Outdated Show resolved Hide resolved
@dmitrii-ubskii dmitrii-ubskii changed the title Entry point Improve entry point runner UX Nov 30, 2023
Comment on lines -100 to +106
if [ $DEBUG ]; then
exec $JAVA_BIN ${JAVAOPTS} -ea -cp "${CLASSPATH}" -Dtypedb.dir="${TYPEDB_HOME}" \
${TYPEDB_SERVER_CLASS} "${@:2}"
else
exec $JAVA_BIN ${JAVAOPTS} -cp "${CLASSPATH}" -Dtypedb.dir="${TYPEDB_HOME}" \
${TYPEDB_SERVER_CLASS} "${@:2}"
fi
else
echo "Invalid argument: $1. Possible commands are: "
echo " Server: typedb server [--help]"
echo " Enterprise: typedb enterprise [--help]"
echo " Console: typedb console [--help]"
exit 1
fi
CLASSPATH="${TYPEDB_SERVER_DIR}/conf/:${TYPEDB_SERVER_LIB_DIR}/*"

# exec replaces current shell process with java so no commands after these ones will ever get executed
exec ${JAVA_BIN} ${JAVAOPTS} ${EXTRAOPTS} -cp "${CLASSPATH}" -Dtypedb.dir="${TYPEDB_HOME}" ${TYPEDB_SERVER_CLASS} "${@:2}"
;;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compresed and replaced the "if debug add flag" switch with more idiomatic and extensible EXTRAOPTS variable

@@ -20,77 +20,88 @@ IF %TYPEDB_HOME:~-1%==\ SET TYPEDB_HOME=%TYPEDB_HOME:~0,-1%

where java >NUL 2>NUL
if %ERRORLEVEL% GEQ 1 (
echo Java is not installed on this machine.
echo TypeDB needs Java 11+ in order to run. See the following setup guide: http://docs.vaticle.com/docs/get-started/setup-guide
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obsolete link

Comment on lines -55 to +45
start java %CONSOLE_JAVAOPTS% -cp "%G_CP%" -Dtypedb.dir="%TYPEDB_HOME%" com.vaticle.typedb.console.TypeDBConsole %2 %3 %4 %5 %6 %7 %8 %9
java %CONSOLE_JAVAOPTS% -cp "%G_CP%" -Dtypedb.dir="%TYPEDB_HOME%" com.vaticle.typedb.console.TypeDBConsole %2 %3 %4 %5 %6 %7 %8 %9
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

console is a CLI which should stay in the host command prompt

Comment on lines -70 to 69
start java %SERVER_JAVAOPTS% -cp "%G_CP%" -Dtypedb.dir="%TYPEDB_HOME%" com.vaticle.typedb.core.server.TypeDBServer %2 %3 %4 %5 %6 %7 %8 %9
if "%2"=="--help" (
java %SERVER_JAVAOPTS% -cp "%G_CP%" -Dtypedb.dir="%TYPEDB_HOME%" com.vaticle.typedb.core.server.TypeDBServer %2 %3 %4 %5 %6 %7 %8 %9
) else (
start cmd /c java %SERVER_JAVAOPTS% -cp "%G_CP%" -Dtypedb.dir="%TYPEDB_HOME%" com.vaticle.typedb.core.server.TypeDBServer %2 %3 %4 %5 %6 %7 %8 %9 ^|^| pause
)
goto exit
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two changes here:

  • typedb server --help (as suggested by the usage print) no longer opens a new window, but rather prints the help in the current cmd window
  • otherwise, we use start cmd /c [...] ^|^| pause which prevents the window from automatically closing if (and only if) the server encounters an error and stops with a non-zero exit code, so that the user has a chance to read the log. Ctrl+C still shuts down the server and closes the window without triggering pause.

@flyingsilverfin flyingsilverfin merged commit a338f2a into vaticle:master Nov 30, 2023
3 checks passed
flyingsilverfin pushed a commit to vaticle/typedb that referenced this pull request Dec 1, 2023
## Usage and product changes

We update to the updated entry point for the assembled TypeDB Core,
which omits `console` from the usage help if it is not present to avoid
confusion. See #6942 for more
details.

The command to boot up the server (unchanged):
```
typedb server --server.address=<address>
``` 
The command to boot up the console:
```
typedb console --core=<address>
```

We also improve the UX of the windows version of the entry point.
Console no longer opens in a new window, `--help` is printed inline as
expected, and in the event of the server failure, the logs are displayed
to the user. See vaticle/typedb-common#158 for
more details.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants