diff --git a/deploy.cmd b/deploy.cmd new file mode 100644 index 0000000..d80adb3 --- /dev/null +++ b/deploy.cmd @@ -0,0 +1,16 @@ +gp 'test' +git push heroku + + +heroku logs --tail + +heroku + +/app/.heroku/python/lib/python3.8/site-packages/pyhanlp/static/ +下载 https://file.hankcs.com/hanlp/hanlp-1.8.4-release.zip 到 /app/.heroku/python/lib/python3.8/site-packages/pyhanlp/static/hanlp-1.8.4-release.zip +/app/.heroku/python/lib/python3.8/site-packages/pyhanlp/static/hanlp-1.8.4-release.zip + +wget -o data-for-1.8.4.zip https://file.hankcs.com/hanlp/data-for-1.7.5.zip + +wget -o data-for-1.8.4.zip http://software.haokeniu.com/data-for-1.7.5.zip +data-for-1.8.4.zip \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..7c0743d --- /dev/null +++ b/main.py @@ -0,0 +1,79 @@ +# -*- coding: utf-8 -*- +import os +import sys + +import uvicorn +from apps.base.hello import hello, logger +from apps.base.conf import conf, LogLevel +from apps.route import create_app + +root_path = os.getcwd() +sys.path.append(root_path) + +abs_path = "" +if getattr(sys, 'frozen', False): + abs_path = os.path.dirname(os.path.abspath(sys.executable)) +elif __file__: + abs_path = os.path.dirname(os.path.abspath("travelgpt")) + +app = create_app() +if __name__ == "__main__": + log_config = { + "version": 1, + "disable_existing_loggers": "false", + "formatters": { + "default": { + "()": "uvicorn.logging.DefaultFormatter", + "fmt": "%(levelprefix)s %(message)s" + }, + "access": { + "()": "uvicorn.logging.AccessFormatter", + "fmt": "%(asctime)s | %(levelprefix)s |%(client_addr)s - \"%(request_line)s\" %(status_code)s" + } + }, + "handlers": { + "default": { + "formatter": "default", + "class": "logging.StreamHandler", + "stream": "ext://sys.stderr" + }, + "access": { + "formatter": "access", + "class": "logging.StreamHandler", + "stream": "ext://sys.stdout" + } + }, + "loggers": { + "uvicorn": { + "handlers": [ + "default" + ], + "level": "DEBUG" + }, + "uvicorn.error": { + "level": "DEBUG" + }, + "uvicorn.access": { + "handlers": [ + "access" + ], + "level": "DEBUG", + "propagate": "false" + }, "sqlalchemy.engine": { + "level": "DEBUG" + } + } + } + try: + name_app = os.path.basename(__file__)[0:-3] + print("App Directory:::::", os.getcwd()) + hello() + uvicorn.run(app=f'{name_app}:app', + host=conf.host, + port=conf.port, + reload=False, + log_level=LogLevel.lower(), + log_config=log_config + ) + except Exception as e: + logger.exception("Service Internal Error!", e) \ No newline at end of file diff --git a/main.spec b/main.spec new file mode 100644 index 0000000..1036c39 --- /dev/null +++ b/main.spec @@ -0,0 +1,37 @@ +# -*- mode: python ; coding: utf-8 -*- + +a = Analysis( + ['main.py'], + pathex=[], + binaries=[], + datas=[], + hiddenimports=[], + hookspath=[], + hooksconfig={}, + runtime_hooks=[], + excludes=[], + noarchive=False, + optimize=0, +) +pyz = PYZ(a.pure) + +exe = EXE( + pyz, + a.scripts, + a.binaries, + a.datas, + [], + name='main', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=True, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None, +) \ No newline at end of file