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.new(List<
String> args, SerializationManagerServer serializationManager, EndpointDispatch endpoints, {ServerpodConfig? config, AuthenticationHandler? authenticationHandler, HealthCheckHandler? healthCheckHandler, Map<String, dynamic> httpResponseHeaders = _defaultHttpResponseHeaders, Map<String, dynamic> httpOptionsResponseHeaders = _defaultHttpOptionsResponseHeaders, SecurityContextConfig? securityContextConfig, ExperimentalFeatures? experimentalFeatures}) - Creates a new Serverpod.
Properties
- authenticationHandler → AuthenticationHandler?
-
Custom AuthenticationHandler used to authenticate users.
final
- caches → Caches
-
Caches used by the server.
no setter
- 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
- endpoints → EndpointDispatch
-
Definition of endpoints used by the server. This is typically generated.
final
- experimental → ExperimentalApi
-
Access experimental features.
no setter
-
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.
no setter
- 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 SerializableModel, 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,
if the database integration is enabled. The storages are named
public
andprivate
. 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.
no setter
-
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, SerializableModel? object, DateTime time, {String? identifier}) → Future< void> - Calls a FutureCall by its name at the specified time, optionally passing a SerializableModel object as parameter.
-
futureCallWithDelay(
String callName, SerializableModel? object, Duration delay, {String? identifier}) → Future< void> - Calls a FutureCall by its name after the specified delay, optionally passing a SerializableModel object as parameter.
-
getPassword(
String key) → String? - Retrieves a password for the given key. Passwords are loaded from the config/passwords.yaml file.
-
loadCustomPasswords(
List< ({String alias, String envName})> envPasswords) → void - Registers passwords to be loaded from the env variables. The password can be accessed with the getPassword method. The envName is the name of the environment variable that contains the password. The alias is the key used to access the the password with the getPassword method. The alias also maps to the name in the config/passwords.yaml file. This method may throw a ArgumentError if any Serverpod reserved passwords are used as aliases or environment variables.
-
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< SerializableModel> 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, int? signalNumber}) → Future< void> -
Shuts down the Serverpod and all associated servers.
If
exitProcess
is set to false, the process will not exit at the end of the shutdown. -
start(
{bool runInGuardedZone = true}) → 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