title: Running airflow within a conda environment and with systemd fails to launch
body: <p>I would like to install airflow via conda and use systemd to control airflow on Ubuntu.  I've been able to successfully install airflow into a conda environment with the following steps, but I have not been able to correctly configure systemd to work with airflow.</p>
  
  <p>Details:</p>
  
  <ul>
  <li>Ubuntu 18.04</li>
  <li>Python 3.7.4</li>
  <li>Airflow 1.10.4</li>
  </ul>
  
  <p>I've seen <a href="https://stackoverflow.com/questions/52310217/apache-airflow-systemd-file-using-a-conda-env">SO #52310217</a>, but the question remains unresolved.</p>
  
  <p>Here are the steps that I've taken to install and run airflow from the command line:</p>
  
  <pre><code>$ conda create --name airflow -c conda-forge airflow
  $ conda activate airflow
  $ export AIRFLOW_HOME=~/airflow
  $ airflow initdb
  
  $ airflow scheduler
  $ airflow webserver
  </code></pre>
  
  <p>From here, I've created the following files in <code>/etc/systemd/system/</code>:</p>
  
  <hr>
  
  <pre><code># /etc/systemd/system/airflow-scheduler.service
  [Unit]
  Description=Airflow scheduler daemon
  After=network.target postgresql.service mysql.service redis.service rabbitmq-server.service
  Wants=postgresql.service mysql.service redis.service rabbitmq-server.service
  
  [Service]
  Environment="PATH=/home/ubuntu/python/envs/airflow/bin"
  User=airflow
  Group=airflow
  Type=simple
  ExecStart=/home/curtis/miniconda3/envs/airflow/bin/airflow scheduler
  Restart=always
  RestartSec=5s
  
  [Install]
  WantedBy=multi-user.target
  </code></pre>
  
  <hr>
  
  <pre><code># /etc/systemd/system/airflow-webserver.service
  [Unit]
  Description=Airflow webserver daemon
  After=network.target postgresql.service mysql.service redis.service rabbitmq-server.service
  Wants=postgresql.service mysql.service redis.service rabbitmq-server.service
  
  [Service]
  Environment="PATH=/home/ubuntu/python/envs/airflow/bin"
  User=airflow
  Group=airflow
  Type=simple
  ExecStart=/home/curtis/miniconda3/envs/airflow/bin/airflow webserver -p 8085 --pid /home/curtis/airflow/airflow-webserver.pid
  Restart=on-failure
  RestartSec=5s
  PrivateTmp=true
  
  [Install]
  WantedBy=multi-user.target
  </code></pre>
  
  <hr>
  
  <p>After creating the above files, I issued the following commands, but nothing happened.</p>
  
  <pre><code>sudo systemctl daemon-reload
  sudo systemctl enable airflow-scheduler
  sudo systemctl start airflow-scheduler
  sudo systemctl enable airflow-webserver
  sudo systemctl start airflow-webserver
  </code></pre>
  
  <p>If I enter the <code>ExecStart</code> command directly in the terminal window, airflow scheduler and airflow webserver start as expected. For this reason, I don't think it's a problem with airflow, but rather something that I'm missing from the <code>systemd</code> configuration.</p>
  
  <p>I'm not sure what to take away from this, but here is the status of airflow-scheduler and airflow-webserver.</p>
  
  <hr>
  
  <pre><code>[curtis:~/airflow/logs/scheduler] [airflow] 4 $ sudo systemctl status airflow-scheduler
  ● airflow-scheduler.service - Airflow scheduler daemon
     Loaded: loaded (/etc/systemd/system/airflow-scheduler.service; enabled; vendor preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Mon 2019-08-19 22:36:35 PDT; 3s ago
    Process: 5623 ExecStart=/home/curtis/miniconda3/envs/airflow/bin/airflow scheduler (code=exited, status=217/USER)
   Main PID: 5623 (code=exited, status=217/USER)
  </code></pre>
  
  <hr>
  
  <pre><code>[curtis:~/airflow/logs/scheduler] [airflow] 3 $ sudo systemctl status airflow-webserver
  ● airflow-webserver.service - Airflow webserver daemon
     Loaded: loaded (/etc/systemd/system/airflow-webserver.service; enabled; vendor preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Mon 2019-08-19 22:36:46 PDT; 895ms ago
    Process: 5805 ExecStart=/home/curtis/miniconda3/envs/airflow/bin/airflow webserver -p 8085 --pid /home/curtis/airflow/airflow-webserver
   Main PID: 5805 (code=exited, status=217/USER)
  </code></pre>
  
  <hr>