how can I prevent genserver to start when running the seeds.ex file?
I have this cronjob that is running when I start the server, but I noticed that it starts too when I run the seeds.ex file. It wouldn’t be so bad but when the script is finished then the cronjob stops and that is bad for my data.
I want somehow the genserver to start only when I start the server.
seeds.exs does need your application to be started. So it will start of course everything in your application. The hole supervision tree.
But also the seeds.exs isn’t meant to be run periodically. Usually its meant to be run once at an initial deploy of the application. Thats why it is called seeds. One usually doesn’t throw more seeds on the acre when the wheat is already growing…
mix run --no-start seeds.exs might work, but then you have do a lot of bootstrapping on your own, like starting your repo, the connection pool, other needed stuff.
I do assume your app is running as a release? Have you considered a “custom command” as described in the running migrations section?
That will actually run in th context of your already started application and not spawn a new one in parallel.
If you are not running a release created by distillery you can use other means to connect to the already running node and make it run your database updates.
Or last but not least, you can of course create those in plain SQL and just run them through your database…