diff --git a/operational b/operational index 46ba2db2c5e74ac2bd4db024680422971541a00e..cd17ca8f90062127b7574342a5c93b17ad7b4820 100644 --- a/operational +++ b/operational @@ -1,9 +1,26 @@ * COMMENT -*- mode: org -*- #+Date: 2014-05-09 -Time-stamp: <2016-09-06> +Time-stamp: <2016-09-08> #+STARTUP: content * current :entry: ** +** 2016-09-08 integrate sanity-check +- in Makefile + check: just-test ++sanity-check: ++ $(PYTHON) wechat_article_saver_daemon/sanity_check.py + check-coding-style: bootstrap-dev + +- add the template with a dumb check. + +** 2016-09-08 support updating site file, deb scripts etc after project is generated. +- the domain in site file could change. +- the pkg name could change. +- whether to use uwsgi could change. + +./utils/update_site_file.py --domain foo.emacsos.com --uwsgi +./utils/update_site_file.py --domain foo.emacsos.com --http + ** 2016-09-06 support adding celery to existing project. - This will add a celeryconfig module and a tasks module. see examples in @@ -21,6 +38,16 @@ see example ~/.pylintrc ** 2016-07-27 package name should not have -, auto convert it to _. - package name is part of module name, - is not valid there. +** 2016-06-30 update it for use with default debian config. (non-yy env) +- update nginx config file +- add support for systemd +- create /data if it doesn't exist. auto use sudo to create the dir if it + doesn't exist. + + make sure it works on fresh system. use a VM to test it. +** 2014-05-09 add sphinx support +* later :entry: +* done :entry: ** DONE 2016-06-30 make "lein new python bar" work, without --to-dir . chmod -R +x utils/ @@ -42,13 +69,6 @@ chmod -R +x utils/ I think it could be nil when --to-dir is not used. yes. it's null when user doesn't use --to-dir option. -** 2016-06-30 update it for use with default debian config. (non-yy env) -- update nginx config file -- add support for systemd -- create /data if it doesn't exist. auto use sudo to create the dir if it - doesn't exist. - - make sure it works on fresh system. use a VM to test it. ** DONE 2016-06-30 use python3 in venv by default. - make old code work with python3. - add future imports @@ -124,5 +144,3 @@ chmod -R +x utils/ - it requires me listing all template and plain files. this is bad. should just generate the file list on the fly. -** 2014-05-09 add sphinx support -* later :entry: diff --git a/project.clj b/project.clj index 65257dc227370ff2cc9e7ac459d2cc20f5405223..c6682356d7a90eb6c5e163e83e4997c158264747 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject python/lein-template "0.13.0" +(defproject python/lein-template "0.14.0" :description "lein template for a python project" :repositories [["snapshots" {:url "http://devserv.game.yy.com/nexus/content/repositories/snapshots" diff --git a/src/leiningen/new/python.clj b/src/leiningen/new/python.clj index 1b29b90244979aa194350f1fedb7f45baba93d33..b187ad6dedcc7ee2382e6611833f758efaea6c63 100644 --- a/src/leiningen/new/python.clj +++ b/src/leiningen/new/python.clj @@ -34,6 +34,7 @@ (.format (new SimpleDateFormat "yyyy-MM-dd") (.getTime cal)))} template-files ["Makefile" + "fabfile.py" "requirements.txt" "requirements-dev.txt" "setup.py" @@ -49,6 +50,7 @@ "conf/logrotate.conf" "conf/uwsgi.ini" "conf/uwsgi.upstart" + "conf/web.upstart" "git-hooks/post-commit" "git-hooks/post-merge" "git-hooks/pre-commit" diff --git a/src/leiningen/new/python/.gitignore b/src/leiningen/new/python/.gitignore index e3affb04f261ff61a74bb7e982d8d5ea5b7ba88a..07a0db828e1c5b4650c3627a0fcbf1489835180c 100644 --- a/src/leiningen/new/python/.gitignore +++ b/src/leiningen/new/python/.gitignore @@ -1,4 +1,5 @@ # BEGIN regular python ignore list +.venv/ bin/ include/ lib/python2.7/ @@ -15,4 +16,5 @@ __pycache__/ .tox *.deb doc/_build/ +TAGS # ENG regular python ignore list diff --git a/src/leiningen/new/python/Makefile b/src/leiningen/new/python/Makefile index 789ca8ce886deef3d6e3dec6dd9d468b33d941ce..4ac8cc0e3080c46e29a4b4ea202fbcffb4b712a3 100644 --- a/src/leiningen/new/python/Makefile +++ b/src/leiningen/new/python/Makefile @@ -3,7 +3,7 @@ PYTHONPATH := . VENV := .venv PYTEST := env PYTHONPATH=$(PYTHONPATH) PYTEST=1 $(VENV)/bin/py.test PYLINT := env PYTHONPATH=$(PYTHONPATH) $(VENV)/bin/pylint --disable=I0011 --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" -PEP8 := env PYTHONPATH=$(PYTHONPATH) $(VENV)/bin/pep8 --repeat --ignore=E202,E501 +PEP8 := env PYTHONPATH=$(PYTHONPATH) $(VENV)/bin/pep8 --repeat --ignore=E202,E501,E402 PYTHON := env PYTHONPATH=$(PYTHONPATH) $(VENV)/bin/python PIP := $(VENV)/bin/pip diff --git a/src/leiningen/new/python/conf/http.site b/src/leiningen/new/python/conf/http.site index 81e7cce86b564b6c81ce3289aaa0c818aa521a42..087c0f880ea346f625c9795739c2fd7448914c77 100644 --- a/src/leiningen/new/python/conf/http.site +++ b/src/leiningen/new/python/conf/http.site @@ -33,9 +33,19 @@ server { } location / { - include uwsgi_params; - uwsgi_pass 127.0.0.1:8082; - uwsgi_read_timeout 300; - uwsgi_send_timeout 300; + proxy_pass http://127.0.0.1:8082; + proxy_http_version 1.1; + proxy_set_header Connection ""; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } + + # location / { + # include uwsgi_params; + # uwsgi_pass 127.0.0.1:8082; + # uwsgi_read_timeout 300; + # uwsgi_send_timeout 300; + # } } diff --git a/src/leiningen/new/python/conf/https.site b/src/leiningen/new/python/conf/https.site index 8a405d2fcf481d441827d87f9fa82af50b572ddd..a6e5bc2d155c7c1e3d86b820e9adf1c674ec74fa 100644 --- a/src/leiningen/new/python/conf/https.site +++ b/src/leiningen/new/python/conf/https.site @@ -50,9 +50,19 @@ server { } location / { - include uwsgi_params; - uwsgi_pass 127.0.0.1:8082; - uwsgi_read_timeout 300; - uwsgi_send_timeout 300; + proxy_pass http://127.0.0.1:8082; + proxy_http_version 1.1; + proxy_set_header Connection ""; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } + + # location / { + # include uwsgi_params; + # uwsgi_pass 127.0.0.1:8082; + # uwsgi_read_timeout 300; + # uwsgi_send_timeout 300; + # } } diff --git a/src/leiningen/new/python/conf/web.upstart b/src/leiningen/new/python/conf/web.upstart new file mode 100644 index 0000000000000000000000000000000000000000..a9a48d3cd1c7d005b4be48a9d2ba7ca4c6c42bca --- /dev/null +++ b/src/leiningen/new/python/conf/web.upstart @@ -0,0 +1,18 @@ +description "TODO add description here" +start on runlevel [2345] +stop on runlevel [06] + +env LANG=en_US.UTF-8 +env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +env PORT=8082 + +chdir /opt/{{name}} +setuid www-data +setgid www-data + +exec make run + +kill timeout 10 + +respawn +respawn limit 10 5 diff --git a/src/leiningen/new/python/deb-scripts/after-install.sh b/src/leiningen/new/python/deb-scripts/after-install.sh index 8da906e19a3ae1d011e5a443fe085514df5a36a3..0a61e4658e0eb85afbab9e7953035d93c158ec45 100644 --- a/src/leiningen/new/python/deb-scripts/after-install.sh +++ b/src/leiningen/new/python/deb-scripts/after-install.sh @@ -20,7 +20,7 @@ make bootstrap install # set how many copies to keep. # install "$PREFIX/conf/logrotate.conf" /etc/logrotate.d/{{name}} -# install "$PREFIX/conf/uwsgi.upstart" /etc/init/{{name}}.conf +# install "$PREFIX/conf/web.upstart" /etc/init/{{name}}.conf # start {{name}} || true # SITE_FILE=/etc/nginx/conf.d/{{name}}.conf diff --git a/src/leiningen/new/python/setup.py b/src/leiningen/new/python/setup.py index 604d58b9fa6f30d9c20f8a2976ea3336bda24f40..30b8e95a917eed33146ecb5f444c0f3dd0a4764c 100644 --- a/src/leiningen/new/python/setup.py +++ b/src/leiningen/new/python/setup.py @@ -47,7 +47,7 @@ setup( 'Development Status :: 3 - Alpha', 'License :: OSI Approved :: GNU General Public License (GPL)', 'License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)', - 'Programming Language :: Python :: 2.7', - # 'Programming Language :: Python :: 3.3' + # 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3.4', ] )