mihai-ciupina
hi,
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.
Thanks
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 8- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
idi527
How is this genserver started normally? Does something make it start in
seeds.exs?NobbZ
seeds.exsdoes need your application to be started. So it will start of course everything in your application. The hole supervision tree.But also the
seeds.exsisn’t meant to be run periodically. Usually its meant to be run once at an initial deploy of the application. Thats why it is calledseeds. One usually doesn’t throw more seeds on the acre when the wheat is already growing…NobbZ
I have digged a bit.
mix run --no-start seeds.exsmight work, but then you have do a lot of bootstrapping on your own, like starting your repo, the connection pool, other needed stuff.But I still think it is a bad idea.
mihai-ciupina
yes but the cronjob puts some data in the database and suddenly is closed, leaving things in air.
I can postpone the cronjob for a minute just to be sure, but is kind of smelly
NobbZ
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…
mihai-ciupina
No, it’s in dev mode.
NobbZ
Even when run via mix only, you can still remote shell into your application and run arbitrary functions. This is even possible via Cron.
But if it’s in dev, why bother at all? Just stop your application, run maintenance task and start the application again.
Dev is for development, not for production use.
mihai-ciupina
My app/server is always stopped when I run my seeds.ex file.
This is how I register my cronjob:
You might not see my situation.
I have the seeds file, the app, and some genserver.
When I do some task first thing I reset the app:
mix echo.reset
This will execute seeds and start genserver(for 1 sec or so)
Then I start the app:
mix pix.server
This will start the app and the genserver.
seeds puts some test data in the database.
Genserver will run once at 10 minutes so that it can detect some changes and copy data to my database.
What I want is:
When I do some task first thing I reset the app:
mix echo.reset
This will execute seeds
Then I start the app:
mix phx.server
This will start the app and the genserver.