Serverpod class

The Serverpod handles all setup and manages the main Server. In addition to the user managed server, it also runs a server for handling the DistributedCache and other connections through the InsightsEndpoint.

Constructors

Serverpod(List<String> args, SerializationManagerServer serializationManager, EndpointDispatch endpoints, {AuthenticationHandler? authenticationHandler, HealthCheckHandler? healthCheckHandler, Map<String, dynamic> httpResponseHeaders = _defaultHttpResponseHeaders, Map<String, dynamic> httpOptionsResponseHeaders = _defaultHttpOptionsResponseHeaders})
Creates a new Serverpod.

Properties

authenticationHandler AuthenticationHandler?
Custom AuthenticationHandler used to authenticate users.
final
caches → Caches
Caches used by the server.
no setter
cluster ↔ ClusterManager
The ClusterManager provides information about other servers in the same server cluster. This method isn't valid until the Serverpod has been started.
latefinal
commandLineArgs ↔ CommandLineArgs
The parsed runtime arguments passed to Serverpod at startup.
latefinal
config ↔ ServerpodConfig
The server configuration, as read from the config/ directory.
getter/setter pair
databaseConfig DatabasePoolManager
The database configuration.
getter/setter pair
endpoints EndpointDispatch
Definition of endpoints used by the server. This is typically generated.
final
filesWhitelistedForInsights Set<String>
Files that are allowed to be accessed through the InsightsEndpoint. File paths are relative to the root directory of the server. Complete directories (including sub directories) can be whitelisted by adding a trailing slash.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
healthCheckHandler HealthCheckHandler?
HealthCheckHandler for any custom health checks. This can be used to check remotely if all services the server is depending on is up and running.
final
httpOptionsResponseHeaders Map<String, dynamic>
HTTP headers used for OPTIONS responses. These headers are sent in addition to the httpResponseHeaders when the request method is OPTIONS.
final
httpResponseHeaders Map<String, dynamic>
HTTP headers used by all API responses. Defaults to allowing any cross origin resource sharing (CORS).
final
logManager → LogManager
The LogManager of the Serverpod, its typically only used internally by the Serverpod. Instead of using this object directly, call the log method on the current Session.
no setter
migrationManager ↔ MigrationManager
The migration manager used by this Serverpod.
getter/setter pair
redisController ↔ RedisController?
The Redis controller used by Serverpod.
getter/setter pair
runMode String
The servers run mode as specified in ServerpodRunMode.
no setter
runtimeSettings RuntimeSettings
Serverpod runtime settings as read from the database.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
serializationManager SerializationManagerServer
SerializationManager used to serialize SerializableEntity, both when sending data to a method in an Endpoint, but also for caching, and FutureCalls.
final
server Server
The main server managed by this Serverpod.
getter/setter pair
serverId String
The id of this Serverpod.
getter/setter pair
serviceServer Server
The service server managed by this Serverpod.
no setter
startedTime DateTime
The time the Serverpod was started.
no setter
storage Map<String, CloudStorage>
Cloud storages used by the serverpod. By default two storages are set up, public and private. The default storages are using the database, which may not be ideal for larger scale applications. Consider replacing the storages with another service such as Google Cloud or Amazon S3, especially in production environments.
final
webServer WebServer
The web server managed by this Serverpod.
getter/setter pair
whitelistedExternalCalls List<String>?
Currently not used.
getter/setter pair

Methods

addCloudStorage(CloudStorage cloudStorage) → void
Adds a CloudStorage to the Serverpod. You can use this method to override the default DatabaseCloudStorage to use S3 or Google Cloud Storage. E.g. see the serverpod_cloud_storage_s3 pub package.
cancelFutureCall(String identifier) Future<void>
Cancels a FutureCall with the specified identifier. If no future call with the specified identifier is found, this call will have no effect.
createSession({bool enableLogging = true}) Future<InternalSession>
Creates a new InternalSession. Used to access the database and do logging outside of sessions triggered by external events. If you are creating a Session you are responsible of calling the close method when you are done.
futureCallAtTime(String callName, SerializableEntity? object, DateTime time, {String? identifier}) Future<void>
Calls a FutureCall by its name at the specified time, optionally passing a SerializableEntity object as parameter.
futureCallWithDelay(String callName, SerializableEntity? object, Duration delay, {String? identifier}) Future<void>
Calls a FutureCall by its name after the specified delay, optionally passing a SerializableEntity object as parameter.
getPassword(String key) String?
Retrieves a password for the given key. Passwords are loaded from the config/passwords.yaml file.
logVerbose(String message) → void
Logs a message to the console if the logging command line argument is set to verbose.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerFutureCall(FutureCall<SerializableEntity> call, String name) → void
Registers a FutureCall with the Serverpod and associates it with the specified name.
reloadRuntimeSettings() Future<void>
Reloads the runtime settings from the database.
shutdown({bool exitProcess = true}) Future<void>
Shuts down the Serverpod and all associated servers.
start() Future<void>
Starts the Serverpod and all Servers that it manages.
toString() String
A string representation of this object.
inherited
updateRuntimeSettings(RuntimeSettings settings) Future<void>
Updates the runtime settings and writes the new settings to the database.

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

instance Serverpod
The last created Serverpod. In most cases the Serverpod is a singleton object, although it may be possible to run multiple instances in the same program it's not recommended.
no setter