Running the shopify app template remix
When running ‘npm run dev’ or ‘shopify app dev’ no code inside
- shopify.server.ts
- entry.server.tsc
nor any other file that was defined in App structure is run. ‘Run’ in this case meaning when I add a simple console.log(‘Hello World!’) I can not see it in stdout.
The only file that was actually run when the server started seemed to be ‘/app/routes.ts’ like found here: shopify-app-template-remix/app/routes.ts at main · Shopify/shopify-app-template-remix · GitHub. Can someone explain this?
How can I run arbitrary code on my node server using ‘shopify app dev’. Or is that somehow not intended or do I misunderstand the architecture completely?
Even better yet. The first time the code in route.ts is being executed, the .env variable has not been read, so any reads of process.env will result in an undefined. When hot reloading (saving any file, even without changes? CMD+S on mac) and re-executing the code the environment is loaded and all the variables show up as expected.
So this code is not run once per server start but somehow once per hot reload?
PS: What I really want to do is ‘npm run dev’ and then start my gcp pub/sub subscription, pulling/listening on messages. I have not read up on graphql and how that can help with this. Maybe that’s the way to go? Still confused about just calling some code.
Originally posted here Solved: Shopify app dev run startup code - Shopify Community