Picking up environment-variables on Ubuntu vs. macOS The 2019 Stack Overflow Developer Survey...

How can I protect witches in combat who wear limited clothing?

Why can't wing-mounted spoilers be used to steepen approaches?

How to test the equality of two Pearson correlation coefficients computed from the same sample?

ELI5: Why do they say that Israel would have been the fourth country to land a spacecraft on the Moon and why do they call it low cost?

Is there a writing software that you can sort scenes like slides in PowerPoint?

A pet rabbit called Belle

Can smartphones with the same camera sensor have different image quality?

The following signatures were invalid: EXPKEYSIG 1397BC53640DB551

Relations between two reciprocal partial derivatives?

system() function string length limit

Make it rain characters

Would it be possible to rearrange a dragon's flight muscle to somewhat circumvent the square-cube law?

Am I ethically obligated to go into work on an off day if the reason is sudden?

Problems with Ubuntu mount /tmp

Road tyres vs "Street" tyres for charity ride on MTB Tandem

Why not take a picture of a closer black hole?

Simulating Exploding Dice

ipsec, esp: Which key is used to generate the HMAC

Can the prologue be the backstory of your main character?

Is it ok to offer lower paid work as a trial period before negotiating for a full-time job?

What can I do if neighbor is blocking my solar panels intentionally?

In horse breeding, what is the female equivalent of putting a horse out "to stud"?

Windows 10: How to Lock (not sleep) laptop on lid close?

What information about me do stores get via my credit card?



Picking up environment-variables on Ubuntu vs. macOS



The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Come Celebrate our 10 Year Anniversary!How to automatically start supervisord on Linux (Ubuntu)Ubuntu - Supervisord and virtualenvHow to make Supervisord read bash environment variablesHow to point Ubuntu 14.10 Apache2 (mod-wsgi) server to a specific virtual environment (Python 3.4 / Flask)?Supervisor settings environment variables and getting a Error: Unexpected end of key/value pairsPython: How can i read the environment variables / user path variables from another user?Crontab not picking up new conjobPassing multiple environment variables a process managed by a supervisorHow to unset environment variables from scriptDeploy Vapor Project on macOS Server





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















The brief hello.py



import os
from flask import Flask
from dotenv import load_dotenv

app = Flask(__name__)
dotenv_path = os.path.join(os.path.dirname(__file__), '.env')
load_dotenv(dotenv_path)


@app.route('/')
def index():
SECRET_KEY = os.environ.get("SECRET_KEY")
DATABASE_PASSWORD = os.environ.get("DATABASE_PASSWORD")
return SECRET_KEY + DATABASE_PASSWORD + os.linesep


picks up its environment from a .env file



export FLASK_APP=/home/ubuntu/tough/
export SECRET_KEY=ABCD
export DATABASE_PASSWORD=EFGH


After launching the server (using either flask run or gunicorn), asking for curl localhost:8000 reports the expected ABCDEFGH, the two env-vars picked up from .env.



So far so good.



Now we ask supervisor to launch hello.py for us



[program:hello]
command=/home/ubuntu/venv/bin/gunicorn -b localhost:8000 hello:app
directory=/home/ubuntu/tough/
user=ubuntu
stdout_logfile=/home/ubuntu/tough/logs/hello_out.log
stderr_logfile=/home/ubuntu/tough/logs/hello_err.log
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true

[supervisord]
logfile=/home/ubuntu/tough/logs/hello-supervisord.log
pidfile=/home/ubuntu/tough/supervisord.pid


Everything is perfectly fine on macOS (High Sierra). The two environment variables are picked up fine. But on Ubuntu (18.04) I get



File "/home/ubuntu/tough/hello.py", line 14, in index
return SECRET_KEY + DATABASE_PASSWORD + os.linesep
TypeError: unsupported operand type(s) for +: 'NoneType' and 'NoneType'


What might be the difficulty of picking up env-vars on Ubuntu, one that doesn't show up on Darwin?









share





























    0















    The brief hello.py



    import os
    from flask import Flask
    from dotenv import load_dotenv

    app = Flask(__name__)
    dotenv_path = os.path.join(os.path.dirname(__file__), '.env')
    load_dotenv(dotenv_path)


    @app.route('/')
    def index():
    SECRET_KEY = os.environ.get("SECRET_KEY")
    DATABASE_PASSWORD = os.environ.get("DATABASE_PASSWORD")
    return SECRET_KEY + DATABASE_PASSWORD + os.linesep


    picks up its environment from a .env file



    export FLASK_APP=/home/ubuntu/tough/
    export SECRET_KEY=ABCD
    export DATABASE_PASSWORD=EFGH


    After launching the server (using either flask run or gunicorn), asking for curl localhost:8000 reports the expected ABCDEFGH, the two env-vars picked up from .env.



    So far so good.



    Now we ask supervisor to launch hello.py for us



    [program:hello]
    command=/home/ubuntu/venv/bin/gunicorn -b localhost:8000 hello:app
    directory=/home/ubuntu/tough/
    user=ubuntu
    stdout_logfile=/home/ubuntu/tough/logs/hello_out.log
    stderr_logfile=/home/ubuntu/tough/logs/hello_err.log
    autostart=true
    autorestart=true
    stopasgroup=true
    killasgroup=true

    [supervisord]
    logfile=/home/ubuntu/tough/logs/hello-supervisord.log
    pidfile=/home/ubuntu/tough/supervisord.pid


    Everything is perfectly fine on macOS (High Sierra). The two environment variables are picked up fine. But on Ubuntu (18.04) I get



    File "/home/ubuntu/tough/hello.py", line 14, in index
    return SECRET_KEY + DATABASE_PASSWORD + os.linesep
    TypeError: unsupported operand type(s) for +: 'NoneType' and 'NoneType'


    What might be the difficulty of picking up env-vars on Ubuntu, one that doesn't show up on Darwin?









    share

























      0












      0








      0








      The brief hello.py



      import os
      from flask import Flask
      from dotenv import load_dotenv

      app = Flask(__name__)
      dotenv_path = os.path.join(os.path.dirname(__file__), '.env')
      load_dotenv(dotenv_path)


      @app.route('/')
      def index():
      SECRET_KEY = os.environ.get("SECRET_KEY")
      DATABASE_PASSWORD = os.environ.get("DATABASE_PASSWORD")
      return SECRET_KEY + DATABASE_PASSWORD + os.linesep


      picks up its environment from a .env file



      export FLASK_APP=/home/ubuntu/tough/
      export SECRET_KEY=ABCD
      export DATABASE_PASSWORD=EFGH


      After launching the server (using either flask run or gunicorn), asking for curl localhost:8000 reports the expected ABCDEFGH, the two env-vars picked up from .env.



      So far so good.



      Now we ask supervisor to launch hello.py for us



      [program:hello]
      command=/home/ubuntu/venv/bin/gunicorn -b localhost:8000 hello:app
      directory=/home/ubuntu/tough/
      user=ubuntu
      stdout_logfile=/home/ubuntu/tough/logs/hello_out.log
      stderr_logfile=/home/ubuntu/tough/logs/hello_err.log
      autostart=true
      autorestart=true
      stopasgroup=true
      killasgroup=true

      [supervisord]
      logfile=/home/ubuntu/tough/logs/hello-supervisord.log
      pidfile=/home/ubuntu/tough/supervisord.pid


      Everything is perfectly fine on macOS (High Sierra). The two environment variables are picked up fine. But on Ubuntu (18.04) I get



      File "/home/ubuntu/tough/hello.py", line 14, in index
      return SECRET_KEY + DATABASE_PASSWORD + os.linesep
      TypeError: unsupported operand type(s) for +: 'NoneType' and 'NoneType'


      What might be the difficulty of picking up env-vars on Ubuntu, one that doesn't show up on Darwin?









      share














      The brief hello.py



      import os
      from flask import Flask
      from dotenv import load_dotenv

      app = Flask(__name__)
      dotenv_path = os.path.join(os.path.dirname(__file__), '.env')
      load_dotenv(dotenv_path)


      @app.route('/')
      def index():
      SECRET_KEY = os.environ.get("SECRET_KEY")
      DATABASE_PASSWORD = os.environ.get("DATABASE_PASSWORD")
      return SECRET_KEY + DATABASE_PASSWORD + os.linesep


      picks up its environment from a .env file



      export FLASK_APP=/home/ubuntu/tough/
      export SECRET_KEY=ABCD
      export DATABASE_PASSWORD=EFGH


      After launching the server (using either flask run or gunicorn), asking for curl localhost:8000 reports the expected ABCDEFGH, the two env-vars picked up from .env.



      So far so good.



      Now we ask supervisor to launch hello.py for us



      [program:hello]
      command=/home/ubuntu/venv/bin/gunicorn -b localhost:8000 hello:app
      directory=/home/ubuntu/tough/
      user=ubuntu
      stdout_logfile=/home/ubuntu/tough/logs/hello_out.log
      stderr_logfile=/home/ubuntu/tough/logs/hello_err.log
      autostart=true
      autorestart=true
      stopasgroup=true
      killasgroup=true

      [supervisord]
      logfile=/home/ubuntu/tough/logs/hello-supervisord.log
      pidfile=/home/ubuntu/tough/supervisord.pid


      Everything is perfectly fine on macOS (High Sierra). The two environment variables are picked up fine. But on Ubuntu (18.04) I get



      File "/home/ubuntu/tough/hello.py", line 14, in index
      return SECRET_KEY + DATABASE_PASSWORD + os.linesep
      TypeError: unsupported operand type(s) for +: 'NoneType' and 'NoneType'


      What might be the difficulty of picking up env-vars on Ubuntu, one that doesn't show up on Darwin?







      python supervisord gunicorn flask





      share












      share










      share



      share










      asked 4 mins ago









      CalafCalaf

      1044




      1044






















          0






          active

          oldest

          votes












          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "2"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f962941%2fpicking-up-environment-variables-on-ubuntu-vs-macos%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Server Fault!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f962941%2fpicking-up-environment-variables-on-ubuntu-vs-macos%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown