lintel 0.2.0
Loading...
Searching...
No Matches
Public Member Functions | List of all members
lintel::SingleInstanceBootstrapPlugin Class Reference

#include <SingleInstanceBootstrapPlugin.h>

Inheritance diagram for lintel::SingleInstanceBootstrapPlugin:
lintel::BootstrapPlugin

Public Member Functions

 SingleInstanceBootstrapPlugin (const std::shared_ptr< DatabaseConnectionConfigurations > &connectionConfigurations, std::shared_ptr< Configuration > configuration, std::shared_ptr< ProcessName > processName)
 
 ~SingleInstanceBootstrapPlugin () override
 
void onStart () override
 
BootstrapSequence getPriority () override
 
- Public Member Functions inherited from lintel::BootstrapPlugin
 BootstrapPlugin ()=default
 
virtual ~BootstrapPlugin ()=default
 

Detailed Description

Bootstrap plugin that guarantees that a process with a database connection (the server) only runs once.

The plugin acquires an exclusive operating system file lock on <shared memory path>/<process name>.lock and holds it for the lifetime of the process. A second instance of the same process detects the conflict on startup and aborts fatally. The lock is released automatically by the operating system when the process exits or crashes, so no stale locks accumulate.

Processes without a default database connection (e.g. worker processes) are intentionally not restricted and skip the lock entirely.

Constructor & Destructor Documentation

◆ SingleInstanceBootstrapPlugin()

lintel::SingleInstanceBootstrapPlugin::SingleInstanceBootstrapPlugin ( const std::shared_ptr< DatabaseConnectionConfigurations > &  connectionConfigurations,
std::shared_ptr< Configuration >  configuration,
std::shared_ptr< ProcessName >  processName 
)

Construct a SingleInstanceBootstrapPlugin.

Parameters
connectionConfigurationsdatabase connection configurations
configurationapplication configuration containing the shared memory path used for the lock file location
processNamethe process name of the running process

◆ ~SingleInstanceBootstrapPlugin()

lintel::SingleInstanceBootstrapPlugin::~SingleInstanceBootstrapPlugin ( )
override

Member Function Documentation

◆ getPriority()

BootstrapSequence lintel::SingleInstanceBootstrapPlugin::getPriority ( )
overridevirtual

Returns the priority for ordering this plugin in the bootstrap sequence.

Implements lintel::BootstrapPlugin.

◆ onStart()

void lintel::SingleInstanceBootstrapPlugin::onStart ( )
overridevirtual

Acquire the single instance lock unless no database connection exists.

Implements lintel::BootstrapPlugin.


The documentation for this class was generated from the following file: