schultek/jaspr

Trouble consuming Serverpod docs & Samples

Closed this issue · 1 comments

Description

I'm attempting to consume the documentation & samples for the serverpod integration. I failed to get the existing examples working after more time invested than I found reasonable

Steps To Reproduce

cd examples/backend_serverpod/example_server
docker compose down -v  # make sure we're starting clean
docker compose up --build --detach

jaspr serve

yields:

[CLI] Running jaspr in server rendering mode.
✓ [CLI] Done building web assets. (1.8s)
✓ [CLI] Server started. (3ms)
[SERVER] [ERROR] Failed to load config: Exception: Missing database password.
[SERVER] [ERROR] Unhandled exception:
[SERVER] [ERROR] Exception: Missing database password.
[SERVER] [ERROR] #0      new DatabaseConfig._fromJson (package:serverpod_shared/src/config.dart:267:7)
[SERVER] [ERROR] #1      new ServerpodConfig.loadFromMap (package:serverpod_shared/src/config.dart:102:26)
[SERVER] [ERROR] #2      new ServerpodConfig.load (package:serverpod_shared/src/config.dart:136:28)
[SERVER] [ERROR] #3      Serverpod._loadConfig (package:serverpod/src/server/serverpod.dart:403:32)
[SERVER] [ERROR] #4      new Serverpod (package:serverpod/src/server/serverpod.dart:300:19)
[SERVER] [ERROR] #5      run (package:example_server/server.dart:15:15)
[SERVER] [ERROR] #6      main (file:///Users/ewannisbet/repos/jaspr/examples/backend_serverpod/example_server/bin/main.dart:6:3)
[SERVER] [ERROR] #7      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:295:33)
[SERVER] [ERROR] #8      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
[SERVER] 

as an example I'd expect this to work, but ok I'll play nice and populate the config/passwords.yaml & try again:

jaspr serve                                                                                                                                          2:00:29  ☁  main ☂ ⚡ ✭
[CLI] Running jaspr in server rendering mode.
✓ [CLI] Done building web assets. (1.8s)
✓ [CLI] Server started. (3ms)
[SERVER] SERVERPOD version: 2.0.2, dart: 3.4.3 (stable) (Tue Jun 4 19:51:39 2024 +0000) on "macos_arm64", time: 2024-08-04 01:00:34.379872Z
[SERVER] mode: development, role: monolith, logging: normal, serverId: default
[SERVER] [ERROR] Failed to get installed migrations: DatabaseException: relation "serverpod_migrations" does not exist
[SERVER] [ERROR] WARNING: The database does not match the target database:
[SERVER] [ERROR] - Table "serverpod_cloud_storage" is missing.
[SERVER] [ERROR] - Table "serverpod_cloud_storage_direct_upload" is missing.
[SERVER] [ERROR] - Table "serverpod_future_call" is missing.
[SERVER] [ERROR] - Table "serverpod_health_connection_info" is missing.
[SERVER] [ERROR] - Table "serverpod_health_metric" is missing.
[SERVER] [ERROR] - Table "serverpod_log" is missing.
[SERVER] [ERROR] - Table "serverpod_message_log" is missing.
[SERVER] [ERROR] - Table "serverpod_method" is missing.
[SERVER] [ERROR] - Table "serverpod_migrations" is missing.
[SERVER] [ERROR] - Table "serverpod_query_log" is missing.
[SERVER] [ERROR] - Table "serverpod_readwrite_test" is missing.
[SERVER] [ERROR] - Table "serverpod_runtime_settings" is missing.
[SERVER] [ERROR] - Table "serverpod_session_log" is missing.
[SERVER] [ERROR] Hint: Did you forget to apply the migrations (--apply-migrations) or run a repair migration (--apply-repair-migration)?
[SERVER] [ERROR] Failed to load runtime settings. DatabaseException: relation "serverpod_runtime_settings" does not exist
[SERVER] [ERROR] Failed to store runtime settings. DatabaseException: relation "serverpod_runtime_settings" does not exist
[SERVER] Insights listening on port 8081
[SERVER] Server default listening on port 8080
[SERVER] No webserver relic templates found, template directory path: "web/templates".
[SERVER] Webserver listening on port 8082
[SERVER] [ERROR] 2024-08-04 01:00:34.835066Z Internal server error. Failed to connect to database in future call manager.
[SERVER] [ERROR] DatabaseException: relation "serverpod_future_call" does not exist
[SERVER] [ERROR] #0      DatabaseConnection._query (package:serverpod/src/database/adapters/postgres/database_connection.dart:404:9)
[SERVER] [ERROR] <asynchronous suspension>
[SERVER] [ERROR] #1      DatabaseConnection._mappedResultsQuery (package:serverpod/src/database/adapters/postgres/database_connection.dart:458:18)
[SERVER] [ERROR] <asynchronous suspension>
[SERVER] [ERROR] #2      DatabaseConnection._deserializedMappedQuery (package:serverpod/src/database/adapters/postgres/database_connection.dart:476:18)
[SERVER] [ERROR] <asynchronous suspension>
[SERVER] [ERROR] #3      DatabaseConnection.deleteWhere (package:serverpod/src/database/adapters/postgres/database_connection.dart:288:12)
[SERVER] [ERROR] <asynchronous suspension>
[SERVER] [ERROR] #4      FutureCallManager._checkQueue (package:serverpod/src/server/future_call_manager.dart:107:18)
[SERVER] [ERROR] <asynchronous suspension>
[SERVER] [ERROR] 
[SERVER] [ERROR] Local stacktrace:
[SERVER] [ERROR] #0      FutureCallManager._checkQueue (package:serverpod/src/server/future_call_manager.dart:145:36)
[SERVER] [ERROR] <asynchronous suspension>

since I have some serverpod knowledge:

dart bin/main.dart --apply-migrations
SERVERPOD version: 2.0.2, dart: 3.4.3 (stable) (Tue Jun 4 19:51:39 2024 +0000) on "macos_arm64", time: 2024-08-04 01:01:52.096597Z
mode: development, role: monolith, logging: normal, serverId: default
Applied database migration:
 - 20240321115849503
Insights listening on port 8081
Server default listening on port 8080
No webserver relic templates found, template directory path: "web/templates".
Webserver listening on port 8082
^C

and finally:

jaspr serve
[CLI] Running jaspr in server rendering mode.
✓ [CLI] Done building web assets. (1.8s)
✓ [CLI] Server started. (3ms)
[SERVER] SERVERPOD version: 2.0.2, dart: 3.4.3 (stable) (Tue Jun 4 19:51:39 2024 +0000) on "macos_arm64", time: 2024-08-04 01:02:48.901207Z
[SERVER] mode: development, role: monolith, logging: normal, serverId: default
[SERVER] Insights listening on port 8081
[SERVER] Server default listening on port 8080
[SERVER] No webserver relic templates found, template directory path: "web/templates".
[SERVER] Webserver listening on port 8082

but what does a client see?

curl http://localhost:8082/
Internal Server Error%  

I had a different set of unsuccessful experiences with apps/dart_quotes_server which unless it would be really helpful I'm not going to doc the repro

Expected Behavior

As a developer who has heard about Serverpod & Jaspr (or the other way around 😉), but may have little or no experience in either, I want to quickly (inside 30 mins) get a working implementation running.

Additional Context

Now, I'm not here to complain 😉 so I've solved this for my own purposes. I've made a version of this publicly available at:
https://github.com/thatdogmachine/public_jaspr_serverpod_mini_demo/blob/main/jaspr_serverpod_mini_demo/README.md

I'm open to raising PR(s) to integrate that Serverpod mini demo back into your repo, and / or helping to make the README files a bit more robust, but in the short term I've taken this approach so I can get on with what I'm doing and hopefully still contribute something back.

Nice project BTW 😄 💪

I updated the example and the integration docs.

  • added the passwords.yaml file
  • you can change the jaspr.dev command in pubspec.yaml to 'dart bin/main.dart --apply-migrations'