GenServer servor error at deploy since Phoenix upgrade, may be related to EventStore?

Hi @al2o3cr , thanks for identifying the problem and sending me the related documentation. However, the solution was not exactly what is documented… I’ll go over my failed attempts and finally give my solution.

:no_entry: Migrating with mix
We use mix release so, as documented, we don’t have mix available. Leading to the second solution documented :

:no_entry: Migrating using a helper function
I don’t understand this documented solution; we should use the command eval "MyApp.ReleaseTasks.migrate_event_store()" inside the release folder… Which does not exist because the release fails without the migration of the event store!

cd3fd680: cdg running healthy
--> v428 failed - Failed due to unhealthy allocations - rolling back to job version 427 and deploying as v429 

--> Troubleshooting guide at https://fly.io/docs/getting-started/troubleshooting/
Error abort

To try to do the migration during the deployment, I thought of calling it in my DockerFile:

:no_entry: Migrating with mix in docker
mix event_store.migrate failed with the error :nofile

 => ERROR [build  8/18] RUN mix event_store.migrate                                                                                                                                                 3.0s
------
 > [build  8/18] RUN mix event_store.migrate:
#19 1.498 Generated my_app app
#19 2.903 ** (Mix) Could not load MyApp.Auctions.EventStore, error: :nofile. Please configure your app accordingly or pass a event store with the -e option.
------
Error failed to fetch an image or build from source: error building: executor failed running [/bin/sh -c mix event_store.migrate]: exit code: 1

Same error with the -e option

 => ERROR [build  8/18] RUN mix event_store.migrate -e MyApp.Auctions.EventStore                                                                                                             2.6s
------                                                                                                                                                                                                   
 > [build  8/18] RUN mix event_store.migrate -e MyApp.Auctions.EventStore:
#19 1.469 Generated my_app app
#19 2.556 ** (Mix) Could not load MyApp.Auctions.EventStore, error: :nofile. Please configure your app accordingly or pass a event store with the -e option.
------
Error failed to fetch an image or build from source: error building: executor failed running [/bin/sh -c mix event_store.migrate -e MyApp.Auctions.EventStore]: exit code: 1

:white_check_mark: Migrating using a helper function inside Release.migrate()
So I finally thought of using the release function that we pass to Fly.

Fly.io call this command [deploy] release_command = "/app/bin/my_app eval MyApp.Release.migrate" at every deployment, which ensure everything started, load the app, and call Ecto.Migrator.with_repo().

I added a call to my helper function MyApp.Release.migrate_evenstore and voilà :tada:

Thanks everyone for the help on this :slightly_smiling_face: and sorry for not having updated sooner!

1 Like