$ vi app.py
---
app.run('0.0.0.0',5000,debug=True)
---

$ sudo -i
$ service nginx stop
$ service uwsgi stop

$ vi /etc/nginx/sites-available/default
---
server {
## listen 80 default_server;
## listen [::]:80 default_server ipv6only=on;
listen 5000;

root /usr/share/nginx/html;
index index.html index.htm;

# Make site accessible from http://localhost/
## server_name localhost;
server_name 0.0.0.0;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
##try_files $uri $uri/ =404;
try_files $uri @app;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location @app {
include uwsgi_params;
uwsgi_pass unix:/tmp/uwsgi.sock;
}
}
---

$ vi /etc/uwsgi/apps-available/uwsgi.ini
---
[uwsgi]
chdir=/home/service/service_flask
chmod-socket=666
callable=app
module=app
socket=/tmp/uwsgi.sock
virtualenv=/home/service/service_flask
---

$ cd /home/service/service_flask

$ . bin/activate

$ service nginx restart
$ service uwsgi restart

$ uwsgi /etc/uwsgi/apps-available/uwsgi.ini

$ uwsgi --ini ./uwsgi.ini --py-autoreload 1 //소스변경 반영 옵션설정

$ uwsgi --ini /etc/uwsgi/apps-available/uwsgi.ini --py-autoreload 1

Posted by 앤비
,

heroku 설정 방법

Python 2018. 3. 7. 17:12

Download Heroku CLI for macOS

$ heroku login

$ git clone https://github.com/heroku/python-getting-started.git

$ cd python-getting-started

$ heroku create

$ git push heroku master

$ heroku ps:scale web=1

$ heroku open

$ heroku logs --tail


————————————

$ pip3 install gunicorn #글로벌 설치

> create repository to github

> create clone to GitHub client

$ cd ~/OneDrive/project/github/lonbekim

$ heroku login

$ virtualenv service_flask

$ cd service_flask

$ . bin/activate

$ pip3 install flask

$ vi hello.py

import os
from flask import Flask

app = Flask(__name__)

@app.route('/')
def hello():
return 'Hello World!'


$ vi Procfile

web: gunicorn hello:app


$ gem install foreman

$ foreman start #virturalenv 환경이 아닌 deactivate 환경에서 실행

$ pip3 freeze > requirements.txt

> commit & push to GitHub client

$ git init
$ git add .
$ git commit -m "init"

$ heroku create #virturalenv 환경이 아닌 deactivate 환경에서 실행

$ git push heroku master

$ heroku ps:scale web=1

$ heroku ps

$ heroku open

$ heroku logs #에러 발생

$ git push heroku master # 소스 수정 후 재배포

#소스확인

$ heroku login

$ heroku git:clone -a protected-peak-64324

$ cd protected-peak-64324

$ git add .
$ git commit -am "make it better"
$ git push heroku master




Posted by 앤비
,

$ supervisord --version

$ sudo apt-get remove supervisor

$ easy_install supervisor (apt-get install supervisor)

$ python setup.py install

$ supervisord --version

$ sudo service supervisor start

$ sudo apt-get install supervisor

$ sudo supervisorctl start web

$ sudo supervisord -c /etc/supervisor/supervisord.conf
$ sudo supervisorctl -c /etc/supervisor/supervisord.conf

$ sudo supervisorctl reread
$ sudo supervisorctl update
$ sudo supervisorctl start all

$ ps -ef | grep supervisord

$ kill -s SIGTERM 2503

$ watch -n 1 'ps -ef | grep python | grep -v grep'

Posted by 앤비
,