Coder Social home page Coder Social logo

Sidekiq not loading .env about dotenv HOT 17 CLOSED

bkeepers avatar bkeepers commented on July 22, 2024
Sidekiq not loading .env

from dotenv.

Comments (17)

bkeepers avatar bkeepers commented on July 22, 2024

Can you test the latest version (1.0.2) and see if this is still an issue for you? It should be using Rails.root now to properly require it.

from dotenv.

PedroSena avatar PedroSena commented on July 22, 2024

I'm using dotenv 1.0.2 and having the same issue, even with the initializer

from dotenv.

bkeepers avatar bkeepers commented on July 22, 2024

@PedroSena dotenv 2.0.0 is out now. Can you give that a try and see if you still experience issues?

from dotenv.

PedroSena avatar PedroSena commented on July 22, 2024

Same issue, @bkeepers

from dotenv.

bkeepers avatar bkeepers commented on July 22, 2024

I'm not familiar with how Sidekiq boostraps, so I'd appreciate help looking into the issue. Reopening this issue now.

from dotenv.

parkr avatar parkr commented on July 22, 2024

I'd recommend setting the env vars when starting up the sidekiq master, rather than relying on the sidekiq process(es) to read in the .env file. It's really not meant for production (partly because of weird edge cases like this).

from dotenv.

paul-ylz avatar paul-ylz commented on July 22, 2024

I had used Mike Perham's upstart scripts for loading Sidekiq in production and found that I had to add a line to export the env variables before sidekiq loads.

from dotenv.

PedroSena avatar PedroSena commented on July 22, 2024

Leaving dotenv just for dev/test and loading the variables on /etc/environment for production solved the issue. Thanks for the help

from dotenv.

hbin avatar hbin commented on July 22, 2024

@PedroSena I don't think /etc/environment is a good place to put project-related environment variables.

from dotenv.

assimovt avatar assimovt commented on July 22, 2024

I am having a similar issue, using Runit with Sidekiq and currently manually sourcing every .env file.

from dotenv.

mathieugagne avatar mathieugagne commented on July 22, 2024

Jumping a little late on this but hope it can help.
@assimovt do you cd to your application folder in your Runit config before starting sidekiq?

Here's my capistrano template for a sidekiq runit config:

#!/bin/bash --login

PATH=<%= fetch(:rbenv_path) %>/shims:<%= fetch(:rbenv_path) %>/bin:/usr/local/bin:/usr/bin:/bin
exec 2>&1
cd <%= current_path %> && exec bundle exec sidekiq -e <%= fetch(:rails_env) %>

Works well for me.

from dotenv.

NicolasWebDev avatar NicolasWebDev commented on July 22, 2024

Nobody has any news on that?

I am currently having the same problem, using dotenv and capistrano-sidekiq.

from dotenv.

NicolasWebDev avatar NicolasWebDev commented on July 22, 2024

Actually, it finally worked, with capistrano-sidekiq. Sorry for the noise.
Is this issue still relevant?

from dotenv.

stale avatar stale commented on July 22, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

from dotenv.

wflanagan avatar wflanagan commented on July 22, 2024

This is still the case.

from dotenv.

joschl avatar joschl commented on July 22, 2024

put require 'dotenv/load' right after require 'bundler/setup' into bin/sidekiq

from dotenv.

NathanielAwoke avatar NathanielAwoke commented on July 22, 2024

try restarting your sidekiq server. Any changes make to .env are not picked by sidekiq once the service is started.

from dotenv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.