forked from Telodendria/Telodendria
75 lines
1.8 KiB
Groff
75 lines
1.8 KiB
Groff
|
.Dd $Mdocdate: March 12 2023 $
|
||
|
.Dt MAIN 3
|
||
|
.Os Telodendria Project
|
||
|
.Sh NAME
|
||
|
.Nm Main
|
||
|
.Nd Telodendria daemon entry function.
|
||
|
.Sh DESCRIPTION
|
||
|
.Pp
|
||
|
The
|
||
|
.Fn main
|
||
|
function is the first function that is executed. It is responsible
|
||
|
for setting things up and tearing them down. In order, it:
|
||
|
.Bl -bullet
|
||
|
.It
|
||
|
Creates a default logging configuration, installs the memory hook,
|
||
|
and prints the header.
|
||
|
.It
|
||
|
If running on OpenBSD, or is patched for other operating systems
|
||
|
that support it, executes
|
||
|
.Xr pledge 2
|
||
|
with a minimal set of permissions for security.
|
||
|
.It
|
||
|
Parses the command line arguments and sets the relevant flags.
|
||
|
.It
|
||
|
If running on OpenBSD, or is patched for other operating systems
|
||
|
that support it, executes
|
||
|
.Xr unveil 2
|
||
|
on the configuration file.
|
||
|
.It
|
||
|
parses and processes the configuration file.
|
||
|
.It
|
||
|
If running on OpenBSD, or is patched for other operating systems
|
||
|
that support it, executes
|
||
|
.Xr unveil 2
|
||
|
on the data directory, and then disables all future calls to
|
||
|
.Xr unveil 2 .
|
||
|
.It
|
||
|
Applies all settings from the configuration file.
|
||
|
.It
|
||
|
Changes into the data directory.
|
||
|
.It
|
||
|
Binds the HTTP socket.
|
||
|
.It
|
||
|
If running as the root user and not on OpenBSD or other operating
|
||
|
systems that support
|
||
|
.Xr unveil 2 ,
|
||
|
executes
|
||
|
.Xr chroot 2
|
||
|
on the data directory.
|
||
|
.It
|
||
|
Detects the running user, and\(emif specified in the
|
||
|
configuration\(emdrops permissions.
|
||
|
.It
|
||
|
Sets up the database, and cron runner, then starts
|
||
|
the HTTP server and installs the signal handlers.
|
||
|
.It
|
||
|
Blocks on the HTTP server.
|
||
|
.It
|
||
|
Shuts down the HTTP server, cleans up all memory and
|
||
|
file handles, then exits.
|
||
|
.El
|
||
|
.Sh RETURN VALUE
|
||
|
.Pp
|
||
|
.Fn main
|
||
|
returns
|
||
|
.Va EXIT_SUCCESS
|
||
|
if everything runs correctly and Telodendria is
|
||
|
quit normally. It returns
|
||
|
.Va EXIT_FAILURE
|
||
|
if there was a fatal failure before the HTTP
|
||
|
server could be started.
|
||
|
.Pp
|
||
|
These values are returned to the operating system and
|
||
|
indicate the exit status of the process.
|