Custom Server Startup Operations

SxServer has the ability to run custom processes as the server is starting up. These operations are run by SxServer before it begins listening for client connections.

Each custom service must implement the com.seronix.server.SxStartupProcess interface which specifies a single method


The run method accepts a single parameter of type ServerInstance which is a reference to the server’s configuration parameters.


You configure SxServer to run these classes by adding them to the Server Startup Operations section of the server definition.



Notice
Each startup process is run on the main thread. This ensures the process ‘completes’ before the server is allowed to start.
Warning
Each startup process must run to completion or start another thread to do it’s work – otherwise the server will never start listening for client connections.

Database Access

If your startup process needs a database connection you can obtain a database connection provider like this:

DBConnectionProvider cp = new DBConnectionProvider(serverInstance.getDatabaseSettingsProvider());

The startup process must manage all the database connections it uses. For example, if your process runs successfully and you want to commit all of the database connections it acquired while running you could call commitAllConnections() on the connection provider. Rolling back all connections could be accomplished by calling rollbackAllConnections().