4

When I run zeus:

MY_VAR=MY_VALUE zeus start

Environment stays with that that variable, let's say I want to run Rails server with MY_VAR=MAY_VALUE_2

I have tried:

MY_VAR=MAY_VALUE_2 zeus s

But it does not work. I am using oh-my-zsh, in case that's important.

How can I do that?

sites
  • 21,417
  • 17
  • 87
  • 146

2 Answers2

7

Don't know if you still need help with but if you want to be able to store environmental variables in a file you can use the custom_plan.rb that is generated with zeus init. Below is a copy of my file. I am using Omniauth and need my keys to be easily changeable. You can add server only variables by overloading the server method instead, just know that your initializers will be ran before the server command.

require 'zeus/rails'

class CustomPlan < Zeus::Rails

  def boot

    # Omniauth Keys

    # GOOGLE+
    ENV['GPLUS_KEY']       = 'xxx'
    ENV['GPLUS_SECRET']    = 'xxx'

    # FACEBOOK
    ENV['FACEBOOK_KEY']    = 'xxx'
    ENV['FACEBOOK_SECRET'] = 'xxx'

    super # Finish boot
  end
end

Zeus.plan = CustomPlan.new
Nick
  • 600
  • 1
  • 5
  • 13
  • One of the main points of using an environment variable instead of a settings file is that it's not easy to accidentally commit things like GPLUS_SECRET and FACEBOOK_SECRET. Using a file such as this brings this problem back. I wish there was a better option. – Gerry Mar 20 '16 at 06:08
  • If I add env variables in custom_plan.rb then my zeus start command fails. Appending env variables at the start of zeus start command worked for me. – Nikhil Mohadikar Sep 27 '19 at 07:48
4

Passing it in zeus start

SOME_ENV_VAR=test zeus start

Simon Liu
  • 463
  • 5
  • 12