Use lstinline to display inline code instead of texttt
This commit is contained in:
@ -16,7 +16,7 @@ content using TFW.
|
||||
The purpose of this chapter is to further detail the built-in components
|
||||
provided by the framework.
|
||||
As previously mentioned, these components are implemented as event handlers
|
||||
running in the \texttt{solvable} Docker container and frontend
|
||||
running in the \code{solvable} Docker container and frontend
|
||||
components written in Angular.
|
||||
For instance the built-in code editor requires a frontend component and an event
|
||||
handler to function properly, while the frontend component responsible for
|
||||
@ -36,14 +36,14 @@ For example, to inject a command into the terminal one would use a message like
|
||||
}
|
||||
}
|
||||
\end{lstlisting}
|
||||
Notice the \texttt{\textbackslash{}n} at the end of the command.
|
||||
Notice the \code{\n} at the end of the command.
|
||||
By including a newline character, we are also capable of executing commands in the
|
||||
user's terminal.
|
||||
Were this newline omitted, the command would only be written to the terminal
|
||||
(but not automatically executed) for users to inspect and potentially execute themselves.
|
||||
|
||||
Some components emit or broadcast messages on specific events, for instance the
|
||||
\texttt{FSMManagingEventHandler} broadcasts the following message on state transitions:
|
||||
\code{FSMManagingEventHandler} broadcasts the following message on state transitions:
|
||||
\begin{lstlisting}[captionpos=b,caption={An FSM Update message}]
|
||||
{
|
||||
"key": "fsm_update",
|
||||
@ -97,7 +97,7 @@ The timing of pauses and messages is based on the \emph{WPM} --- or Words Per Mi
|
||||
set by developers according to their specific use cases.
|
||||
This creates an experience similar to chatting with someone in real time, as the time
|
||||
it takes for each message to be displayed is depending on the lenght of the previous message.
|
||||
This illusion is made possible through appropriate \texttt{setTimeout()} calls in
|
||||
This illusion is made possible through appropriate \code{setTimeout()} calls in
|
||||
TypeScript and some elementary math to calculate the proper delays in milliseconds based on
|
||||
message lengths:
|
||||
|
||||
@ -110,7 +110,7 @@ message lengths:
|
||||
|
||||
This is the code editor integrated into the frontend of the framework.
|
||||
It allows users to select, display and edit files.
|
||||
Developers can configure which directory on the file system of the \texttt{solvable}
|
||||
Developers can configure which directory on the file system of the \code{solvable}
|
||||
container should the editor list files from.
|
||||
The editor features the ``Deploy'' button referred to earlier in this paper, which is
|
||||
capable of restarting processes that might execute a file visible in the editor.
|
||||
@ -136,11 +136,11 @@ to display, that file is automatially displayed on a new tab in the IDE.
|
||||
|
||||
This allows for really interesting demo opportunities.
|
||||
Lets say I create a file using the terminal on the frontend by executing the
|
||||
command \texttt{touch file.txt}. A new tab on the editor automatically
|
||||
command \code{touch file.txt}. A new tab on the editor automatically
|
||||
appears. If I select it I can confirm that I have successfully created an
|
||||
empty file.
|
||||
After this let's run a \texttt{while} cycle in the command line which
|
||||
peroadically appends some text to \texttt{file.txt}:
|
||||
After this let's run a \code{while} cycle in the command line which
|
||||
peroadically appends some text to \code{file.txt}:
|
||||
\begin{lstlisting}[captionpos=b,caption={Bash While Cycle Writing to a File Periodically},
|
||||
language=bash]
|
||||
while true
|
||||
@ -183,9 +183,9 @@ terminal emulator to do so.
|
||||
|
||||
This component has a tiny server process which is managed by a TFW event handler.
|
||||
This small server is responsible for spawning bash sessions and
|
||||
unix pseudoterminals (or \texttt{pty}s) in the \texttt{solvable} Docker
|
||||
unix pseudoterminals (or \code{pty}s) in the \code{solvable} Docker
|
||||
container.
|
||||
It is also responsible for connecting the master end of the \texttt{pty} to the
|
||||
It is also responsible for connecting the master end of the \code{pty} to the
|
||||
emulator running in your browser and the slave end to the bash session it has
|
||||
spawned.
|
||||
This way users are able to work in the shell displayed on the frontend just like
|
||||
@ -212,21 +212,21 @@ monitoring solution such as Sysdig%
|
||||
\footnote{\href{https://sysdig.comq}{https://sysdig.com}}.
|
||||
I deemed most simiar systems a huge overkill to implement this functionality, and their
|
||||
memory footprints are not something we could afford here.
|
||||
Another way would be to use \texttt{pam\_tty\_audit.so} in the PAM%
|
||||
Another way would be to use \code{pam_tty_audit.so} in the PAM%
|
||||
\footnote{Linux Pluggable Authentication Modules:
|
||||
\href{http://man7.org/linux/man-pages/man3/pam.3.html}
|
||||
{http://man7.org/linux/man-pages/man3/pam.3.html}}
|
||||
configurations responsible for logins, as this allows for various TTY auditing functions,
|
||||
but I have found an ever simpler approach to the problem in the end.
|
||||
By using the inotify system built into TFW, I can set up the user's environment in
|
||||
such a way, that I can enforce and determine the location of the bash \texttt{HISTFILE}%
|
||||
such a way, that I can enforce and determine the location of the bash \code{HISTFILE}%
|
||||
\footnote{This environment variable contains the path to the file bash writes command
|
||||
history to}
|
||||
of the user.
|
||||
This way I can monitor changes made to this file and read the commands executed
|
||||
by the user from it.
|
||||
It is important to keep in mind that the user is able to ``sabotage'' this method%
|
||||
\footnote{By unsetting the \texttt{HISTFILE} envvar for example},
|
||||
\footnote{By unsetting the \code{HISTFILE} envvar for example},
|
||||
but that should not be an issue as this is not a feature that is intended to be
|
||||
used in competitive environments (and if the users of a tutorial intentionally
|
||||
break the system under themselves, well, good for them).
|
||||
@ -248,7 +248,7 @@ experience similar to working in an IDE on your laptop.
|
||||
\section{Process Management}\label{processmanagement}
|
||||
|
||||
The framework includes an event handler capable of managing processes running inside
|
||||
the \texttt{solvable} Docker container.
|
||||
the \code{solvable} Docker container.
|
||||
It's capabilities include starting, stopping and restarting processes.
|
||||
It is also capable of emitting the standard out or standard error logs of processes
|
||||
(by broadcasting TFW messages).
|
||||
@ -273,17 +273,17 @@ a complex system could come with.
|
||||
|
||||
I'll briefly explain such a bug, which I've found to be immersely exciting.
|
||||
During the initial development of this feature all processes inside the
|
||||
\texttt{solvable} Docker container were writing their logs to files
|
||||
\code{solvable} Docker container were writing their logs to files
|
||||
in the FHS%
|
||||
\footnote{The File Hierarchy Standard is a standard maintained by the Linux foundation,
|
||||
defining a common directory structure for compliant systems. See
|
||||
\href{https://wiki.linuxfoundation.org/lsb/fhs}{https://wiki.linuxfoundation.org/lsb/fhs}}
|
||||
location \texttt{/tmp/}.
|
||||
location \code{/tmp/}.
|
||||
All logs coming from the container itself were also logged to this location.
|
||||
This had caused an infinite recursion: when a process would write to \texttt{/tmp/}
|
||||
This had caused an infinite recursion: when a process would write to \code{/tmp/}
|
||||
inotify would invoke a process that would also log to that location causing the kernel to
|
||||
emit more inotify events, which in turn would cause more and more new proesses to spawn
|
||||
and write to \texttt{/tmp/}, causing the whole procedure to repeat again and again.
|
||||
and write to \code{/tmp/}, causing the whole procedure to repeat again and again.
|
||||
This continued until my machine would start to run out of memory and stat swapping
|
||||
pages to disk%
|
||||
\footnote{When a modern operating system runs out of physical RAM, it is going to swap
|
||||
@ -296,7 +296,7 @@ fascinating phenomenon, but those were \emph{very} fun hours.
|
||||
|
||||
\section{FSM Management}
|
||||
|
||||
I have already mentioned the event handler called \texttt{FSMManagingEventHandler},
|
||||
I have already mentioned the event handler called \code{FSMManagingEventHandler},
|
||||
which is responsible for managing the framework FSM.
|
||||
For completeness I chose to include it on this chapter as well.
|
||||
The API it exposes through TFW messages allows client code to attempt stepping the
|
||||
|
Reference in New Issue
Block a user