{"id":27206542,"url":"https://github.com/ddeutils/load-routing","last_synced_at":"2026-05-01T16:36:37.313Z","repository":{"id":212763841,"uuid":"666981814","full_name":"ddeutils/load-routing","owner":"ddeutils","description":"❌ Routing Application deploy to on-premise server","archived":false,"fork":false,"pushed_at":"2024-05-06T13:08:59.000Z","size":391,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-09T23:45:38.766Z","etag":null,"topics":["docker","fastapi","python3","routing-engine"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ddeutils.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-16T08:36:31.000Z","updated_at":"2025-04-07T10:43:16.000Z","dependencies_parsed_at":"2024-02-20T02:44:30.783Z","dependency_job_id":"eeabfbe4-4955-49c7-8fa0-9baa87b1b7c4","html_url":"https://github.com/ddeutils/load-routing","commit_stats":null,"previous_names":["korawica/dfa-fastapi","ddeutils/ddeapp-fastapi","ddeutils/load-routing"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddeutils%2Fload-routing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddeutils%2Fload-routing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddeutils%2Fload-routing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddeutils%2Fload-routing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ddeutils","download_url":"https://codeload.github.com/ddeutils/load-routing/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248131465,"owners_count":21052819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","fastapi","python3","routing-engine"],"created_at":"2025-04-09T23:45:37.367Z","updated_at":"2026-05-01T16:36:37.233Z","avatar_url":"https://github.com/ddeutils.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Data Framework Application: *FastAPI*\n\nData Framework API Application that routing with FastAPI.\n\n**Table of Contents**:\n\n* [Deployment](#deployment)\n* [Testing](#testing)\n\n## Deployment\n\nThis application require run on local intra network (on premise) server. The OS\nis Window server 2016. The solution that we found to run this application is,\n\n1) [Directly with command line](#directly-with-command-line)\n2) [Docker on WSL](#with-docker-on-wsl)\n3) [Window service](#with-window-service)\n4) [Window service by NSSM](#with-window-service-wrapped-by-nssm)\n5) [Window Container on Hyper-V](#with-window-container-on-hyper-v)\n6) ~~[Linux Container on Hyper-V (LCOW)](#with-linux-container-on-hyper-v--lcow-)~~\n7) ~~Window task scheduler~~\n\n### Directly with command line\n\n- First, you must install python version `3.9.13` on your server.\n\n- Start create your python virtual environment for this application.\n\n  ```shell\n  $ python -m vnev vnev\n  $ venv\\Scripts\\activate\n  ```\n- Install all of necessary packages from requirement file.\n\n  ```shell\n  (venv) $ pip install -r requirements.txt --no-cache-dir\n  (venv) $ ren .{demo}.env .env\n  ```\n\n  \u003e [!NOTE]\n  \u003e Make sure for no caching any packages in pip by this command,\n  \u003e ```shell\n  \u003e (venv) $ pip cache purge\n  \u003e ```\n\n- Run your application local\n\n  ```shell\n  (venv) $ uvicorn main:app --reload\n  ```\n\n- (Optional) If you want to stop your application, you can use `Ctrl+C` and deactivate\n  your virtual environment.\n\n  ```shell\n  (venv) $ deactivate\n  ```\n\n### With Docker on WSL\n\n- First, you must check your server installed WSL\n\n  \u003e **Reference**: \\\n  \u003e docs: [Use Docker for windows in WSL](https://pscheit.medium.com/use-docker-for-windows-in-wsl-8fc96ece67c8)\n  \u003e docs: [Unable to locate package docker-ce on a 64bit Ubuntu](https://unix.stackexchange.com/questions/363048/unable-to-locate-package-docker-ce-on-a-64bit-ubuntu)\n\n- Check Docker service running\n\n  ```shell\n  $ sudo service docker start\n  ```\n\n- Go to the project directory (in where your Dockerfile is, containing your app directory).\n\n- Build your FastAPI image:\n\n  ```shell\n  $ sudo docker build -t dedp-fastapi . --no-cache\n  $ sudo docker image ls\n  ```\n\n  Or, use multistage image building:\n\n  ```shell\n  $ sudo docker build -t dedp-fastapi -f multistage.Dockerfile . --no-cache\n  ```\n\n- Run a container based on your image:\n\n  ```shell\n  $ cp .{demo}.env .env\n  $ sudo docker run -d --env-file ./.env --name dedp-fastapi -p 8000:8000 dedp-fastapi\n  ```\n\n  \u003e [!NOTE]\n  \u003e If you want to clear any storage in Docker,\n  \u003e\n  \u003e ```shell\n  \u003e $ docker system prune -a\n  \u003e ```\n\n- Check this container running in background\n\n  ```shell\n  $ curl http://127.0.0.1:8000/api/v1/docs\n  ```\n\n  ```shell\n  $ sudo docker ps\n  ```\n\n### With Window service\n\n- Install the latest pywin32.exe and Window Service requirements with pip\n\n  ```shell\n  $ pip install pywin32 --upgrade --no-cache\n  $ pip install -r requirements.wins.txt --no-cache\n  ```\n\n- Compile your service.py using pyinstaller\n\n  ```shell\n  $ pyinstaller --paths \"%cd%\\venv\\Lib\\site-packages\" \\\n    --onefile service.py \\\n    --hidden-import=win32timezone \\\n    --clean --uac-admin \\\n    --add-data '.env;.'\n  ```\n\n  \u003e [!WARNING]\n  \u003e In argument `--add-data` on unix systems, you should write `:` instead of `;`\n\n  \u003e [!NOTE]\n  \u003e After install `service.py`, it will create `/dist` and `/build` folders\n\n  \u003e [!NOTE]\n  \u003e `--paths`: The pyinstaller will search for imports here \\\n  \u003e `--hidden-import`: Which modules should be imported by pyinstaller from the path\n\n- Installing service with startup == Automatic\n\n  ```shell\n  $ .\\dist\\service.exe --startup=auto install\n  ```\n\n  ```shell\n  $ service.exe start\n  $ service.exe stop\n  $ service.exe debug\n  $ service.exe remove\n  ```\n\n  \u003e [!NOTE]\n  \u003e If you want to set the `StartUp= Manual`, then don't use `--startup=auto`, while installing service \\\n  \u003e If you want to set the `StartUp= Automatic`, then use `--startup=delayed`, while installing service \\\n  \u003e Use `--startup` argument before install argument\n\n  \u003e [!WARNING]\n  \u003e This option has the Bug of `Error 1053: The service did not respond timely`\n  \u003e when start the service while debugging did not raise any error\n\n\n- (Optional) Add file .exe file to Windows Service directly\n\n  ```shell\n  $ sc.exe create \"FastAPIServiceName\" binPath= \"%cd%\\dist\\service.exe\" \\\n    DisplayName= \"FastAPI Service DisplayName\" start= auto\n  ```\n\n  ```shell\n  $ sc.exe create \"FastAPIServiceName\" binPath= \"%cd%\\venv\\Scripts\\python.exe %cd%\\service.py\" \\\n    DisplayName= \"FastAPI Service DisplayName\" start= auto\n  ```\n\n  ```shell\n  $ sc.exe start\n  $ sc.exe delete demo_application\n  ```\n\n- Now your python service is installed as Windows service now. You can see it in Service Manager and registry under:\n\n  `HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\FastAPIServiceName`\n\n\u003e [!NOTE]\n\u003e Another way to install Windows service, `pip install pysc`\n\n\u003e **Reference**: \\\n\u003e docs: [How do you run a Python script as a Service in Windows](https://stackoverflow.com/questions/32404/how-do-you-run-a-python-script-as-a-service-in-windows)\n\n### With Window service wrapped by NSSM\n\n- Downloads and unzip NSSM package to server from [NSSM Download](https://nssm.cc/release/nssm-2.24.zip)\n\n  ```text\n  nssm-{version}\n    ├─── src\n    ├─── win32\n    │    └─── nssm.exe\n    ├─── win64\n    │    └─── nssm.exe      \u003c---- Use this file for run NSSM\n    ├─── ChangeLog.txt\n    └─── README.txt\n  ```\n\n- Install service with NSSM\n\n  ```shell\n  $ .\\nssm\\win64\\nssm.exe install \"FastAPIService\" \"%cd%\\runserver.bat\"\n  ```\n\n- (Optional) Set up logging from NSSM `stdout` and `stderr`\n\n  ```shell\n  $ .\\nssm\\win64\\nssm.exe set \"FastAPIService\" AppStdout \"%cd%\\logs\\FastAPIService.log\"\n  $ .\\nssm\\win64\\nssm.exe set \"FastAPIService\" AppStderr \"%cd%\\logs\\FastAPIService.log\"\n  $ .\\nssm\\win64\\nssm.exe set \"FastAPIService\" AppRotateFiles 1\n  $ .\\nssm\\win64\\nssm.exe set \"FastAPIService\" AppRotateOnline 1\n  $ .\\nssm\\win64\\nssm.exe set \"FastAPIService\" AppRotateSeconds 86400\n  $ .\\nssm\\win64\\nssm.exe set \"FastAPIService\" AppRotateBytes 1048576\n  ```\n\n- Start Window service\n\n  ```shell\n  $ sc.exe start \"FastAPIService\"\n  ```\n\n- (Optional) NSSM command line\n\n  ```shell\n  $ .\\nssm\\win64\\nssm.exe restart \"FastAPIService\"\n  $ .\\nssm\\win64\\nssm.exe edit \"FastAPIService\"\n  $ .\\nssm\\win64\\nssm.exe stop \"FastAPIService\"\n  $ .\\nssm\\win64\\nssm.exe remove \"FastAPIService\"\n  ```\n\n- Check all NSSM service\n\n  ```shell\n  $ Get-WmiObject win32_service | ?{$_.PathName -like '*nssm*'} | select Name, DisplayName, State, PathName\n  ```\n\n\u003e **Reference**: \\\n\u003e docs: [How to run a Python script Windows service NSSM](https://www.mssqltips.com/sqlservertip/7325/how-to-run-a-python-script-windows-service-nssm/)\n\n### With Window Container on Hyper-V\n\n- Install Docker module on PowerShell\n\n```shell\n$ Install-Module DockerMsftProvider -Force\n$ Install-Package Docker -ProviderName DockerMsftProvider -Force\n$ Restart-Computer\n```\n\n### With Linux Container on Hyper-V (LCOW)\n\n- Install Docker module on PowerShell\n\n```shell\n$ Install-WindowsFeature -Name Hyper-V -IncludeManagementTools -Restart\n```\n\n```shell\n$ Install-Module DockerProvider\n$ Install-Package Docker -ProviderName DockerProvider -RequiredVersion preview\n```\n\nReboot your machine manual once again.\n\n```shell\n$ Set-Content -Value \"`{`\"experimental`\":true`}\" -Path C:\\ProgramData\\docker\\config\\daemon.json\n```\n\n- Download [LCOW](https://github.com/linuxkit/lcow/releases) and install in Linux Container folder\n\n```shell\n$ [Environment]::SetEnvironmentVariable(\"LCOW_SUPPORTED\", \"1\", \"Machine\")\n$ Restart-Service docker\n```\n\n### With Window task scheduler\n\n\u003e **Reference**: \\\n\u003e docs: [How to run Python script in Windows](https://www.mssqltips.com/sqlservertip/7111/how-to-run-python-script-in-windows/) \\\n\u003e docs: [Linux Containers on Windows server 2016](https://www.bdrsuite.com/blog/linux-containers-on-windows-server-2016-using-linuxkit/)\n\n## Testing\n\nThe simple way to test this application running by request directly to hearth check route.\n\n```shell\n$ curl http://localhost:8000/health/\n```\n\nLicense\n---\n\nThis project base on MIT License and depend on dependency package license in requirement file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddeutils%2Fload-routing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fddeutils%2Fload-routing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddeutils%2Fload-routing/lists"}