speech-dispatcher: Actions performed on startup
3.3 Actions performed on startup
================================
What follows is an overview of the actions the server takes on startup
in this order:
* Initialize logging stage 1
Set loglevel to 1 and log destination to stderr (logfile is not
ready yet).
* Parse command line options
Read preferred communication method, destinations for logfile and
pidfile
* Establish the '~/.config/speech-dispatcher/' and
'~/.cache/speech-dispatcher/' directories
If pid and conf paths were not given as command line options, the
server will place them in '~/.config/speech-dispatcher/' and
'~/.cache/speech-dispatcher/' by default. If they are not
specified AND the current user doesn't have a system home
directory, the server will fail startup.
The configuration file is pointed to
'~/.config/speech-dispatcher/speechd.conf' if it exists, otherwise
to '/etc/speech-dispatcher/speechd.conf' or a similar system
location according to compile options. One of these files must
exists, otherwise Speech Dispatcher will not know where to find its
output modules.
* Create pid file
Check the pid file in the determined location. If an instance of
the server is already running, log an error message and exit with
error code 1, otherwise create and lock a new pid file.
* Check for autospawning enabled
If the server is started with -spawn, check whether autospawn is
not disabled in the configuration (DisableAutoSpawn config option
in speechd.conf). If it is disabled, log an error message and exit
with error code 1.
* Install signal handlers
* Create unix or inet sockets and start listening
* Initialize Speech Dispatcher
Read the configuration files, setup some lateral threads, start and
initialize output modules. Reinitialize logging (stage 2) into the
final logfile destination (as determined by the command line
option, the configuration option and the default location in this
order of precedence).
After this step, Speech Dispatcher is ready to accept new
connections.
* Daemonize the process
Fork the process, disconnect from standard input and outputs,
disconnect from parent process etc. as prescribed by the POSIX
standards.
* Initialize the speaking lateral thread
Initialize the second main thread which will process the speech
request from the queues and pass them onto the Speech Dispatcher
modules.
* Start accepting new connections from clients
Start listening for new connections from clients and processing
them in a loop.