dokku / dokku-rabbitmq

a rabbitmq plugin for dokku
MIT License
47 stars 19 forks source link

my app is linked to rabbitmq but environment variable RABBITMQ_URL is undefined #63

Closed cocodrino closed 4 years ago

cocodrino commented 4 years ago

Hi, I've an app "botengine_worker" linked to rabbitmq service "rabbitmq"

dokku rabbitmq:linked rabbitmq botengine_worker
-----> Service rabbitmq is linked to botengine_worker

my code try to read this env var but it always return undefined

console.info("RABBITMQ env ", process.env["RABBITMQ_URL"])

do I need some extra step that I'm missing?...please let me know if you need more information or that I run some command...thank you so much

josegonzalez commented 4 years ago

Is the value set in dokku config botengine_worker?

cocodrino commented 4 years ago

Hi @josegonzalez pretty fast :sweat_smile: , yest it's set there

dokku config botengine_worker
 !     Deprecated: Use the 'config:show' command instead
=====> botengine_worker env vars
DOKKU_APP_TYPE:  dockerfile
GIT_REV:         4ba8d8daf89fe3b821cd2cdd1ae8faa02f417771
RABBITMQ_URL:    amqp://rabbitmq:c109xxx241f@dokku-rabbitmq-rabbitmq:5672/rabbitmq
josegonzalez commented 4 years ago

Environment variables are not available during dockerfile build, is that where you are having this issue?

If not, then try running dokku ps:rebuild botengine_worker and checking again.

cocodrino commented 4 years ago

not, it fails running the script, my dockerfile is really ~terrible~ simple

FROM node:10
RUN apt-get update || : && apt-get install python -y
WORKDIR /botengine
COPY /botengine .
RUN yarn run update:deps:yarn
RUN yarn run start:rt_worker
CMD [ "yarn","run", "start:rt_worker" ]

inside the running script I initialize a connection to rabbit, the script starts with this code

console.info("RABBITMQ env ", process.env["RABBITMQ_URL"])

and I get undefined there

josegonzalez commented 4 years ago

you should remove that RUN yarn run start:worker call. This attempts to start the process during the build.

cocodrino commented 4 years ago

oh crap...what a noob mistake :see_no_evil: !..I didn't even notice that I had these...you rock man :metal: thanks!