つづきです。
環境
$ cat /etc/redhat-release CentOS Linux release 7.5.1804 (Core) $ uname -r 3.10.0-862.9.1.el7.x86_64 $ which python /bin/python $ python -V Python 2.7.5 $ id uid=1000(testuser) gid=1000(testuser) groups=1000(testuser)
flask アプリケーションの起動
例として flask アプリケーションを起動してみます。
$ cd ~/green
$ cat <<EOF >server.py
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return 'Hello World\n'
if __name__ == '__main__':
app.run(host='127.0.0.1', port=8000)
EOF
$ pipenv run python server.py
* Serving Flask app "server" (lazy loading)
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:8000/ (Press CTRL+C to quit)
$ curl 127.0.0.1:8000 Hello World
プロジェクトのコピー
$ cd ~
$ cp -a green blue
$ cd blue
$ pipenv --venv
No virtualenv has been created for this project yet!
$ pipenv sync
Creating a virtualenv for this project...
Pipfile: /home/testuser/blue/Pipfile
(snip)
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
All dependencies are now up-to-date!
$ pipenv run python -V
Python 3.7.0
$ pipenv graph
Flask==1.0.2
- click [required: >=5.1, installed: 6.7]
- itsdangerous [required: >=0.24, installed: 0.24]
- Jinja2 [required: >=2.10, installed: 2.10]
- MarkupSafe [required: >=0.23, installed: 1.0]
- Werkzeug [required: >=0.14, installed: 0.14.1]
$ pipenv run python server.py
* Serving Flask app "server" (lazy loading)
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:8000/ (Press CTRL+C to quit)
$ curl 127.0.0.1:8000 Hello World
pipenv sync を実行することで、コピー元と同じ環境を再現することが確認できました。
つづきます。pipenv のプロジェクトを systemdでサービス化します。