#Docker and subscribers

3 messages · Page 1 of 1 (latest)

unkempt cypress
#

Hi,
I have tried to run my Medusa application in a docker environment.
As soon as I run the backend from a docker instance and invokes the product.updated event my subscriber gives this message:
info: Processing product.updated which has 0 subscribers

When I run my medusa backend via "npm start" locally the subscriber works.
Any suggestions?

unkempt cypress
#

I am still struggling with this, when I run my Medus_backend inside my docker environment and I invoke the event "product.updated" I get the following message in my backend logs.

Anybody who has an idea about how I can debug this?

unkempt cypress
#

SOLUTION
I figured out a solution to my problem.

When I realized that the Subscriber (and the eventBusService etc) was never initialized let me into the thought process that my project did not handle my TS files correctly.

It turns out that my subscriber and service while written in TS was not transpiled/compiled as expected.

Then I looked into MedusaJS and TypeScript and found a PR that added support for typescript (medusajs/medusa-starter-default#9)

I then decided to read through the changes and add the ones relevant for my project (for now).

I updated my package.json file with a build script:

"scripts": {
"build": "tsc -p tsconfig.json",
"start": "npm run build && medusa develop"
},
I added the following to the my tsconfig.json

{
"compilerOptions": {
"experimentalDecorators": true,
},
"extends": "./tsconfig.base.json",
"include": ["src"],
"exclude": ["node_modules", "**/*.spec.ts"]
}
I added a tsconfig.base.json file

{
"compilerOptions": {
"lib": ["es5", "es6"],
"target": "esnext",
"allowJs": true,
"esModuleInterop": false,
"module": "commonjs",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"declaration": false,
"sourceMap": false,
"outDir": "./dist",
"rootDir": "src",
"baseUrl": "src"
},
"exclude": ["node_modules"]
}
I updated my develop.sh script to run the same commandos as the npm start script

medusa migrations run

npm run build

medusa develop
Then I ran my docker commands

docker-compose up --build -d

Boom. The Medusa_backend log showcased that the Subscriber was initialized and the subscriber worked as intended.