{"id":17172884,"url":"https://github.com/20tab/uwsgi-emperor-mode","last_synced_at":"2025-09-03T22:35:06.299Z","repository":{"id":73639976,"uuid":"97851444","full_name":"20tab/uwsgi-emperor-mode","owner":"20tab","description":null,"archived":false,"fork":false,"pushed_at":"2019-03-27T10:14:18.000Z","size":14,"stargazers_count":8,"open_issues_count":1,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-10T23:41:53.124Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"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/20tab.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"zenodo":null}},"created_at":"2017-07-20T15:30:35.000Z","updated_at":"2022-08-16T21:19:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"4adb30ae-e016-4b0d-b013-1cf440e69f2f","html_url":"https://github.com/20tab/uwsgi-emperor-mode","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/20tab/uwsgi-emperor-mode","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/20tab%2Fuwsgi-emperor-mode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/20tab%2Fuwsgi-emperor-mode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/20tab%2Fuwsgi-emperor-mode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/20tab%2Fuwsgi-emperor-mode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/20tab","download_url":"https://codeload.github.com/20tab/uwsgi-emperor-mode/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/20tab%2Fuwsgi-emperor-mode/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273523155,"owners_count":25120860,"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","status":"online","status_checked_at":"2025-09-03T02:00:09.631Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-10-14T23:48:37.287Z","updated_at":"2025-09-03T22:35:06.290Z","avatar_url":"https://github.com/20tab.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Definition\n\nThis is a step-by-step guide to install and configure the uWSGI server in _emperor_ mode and with multiple language support. It is mainly intended for macOS environments but, excluding the parts related to bonjour and `launchd`, it can be adapted to other platforms.\n\n# Configuration\n\nPlease make sure to read each of the following sections, and complete them in the specified order.\n\n### uWSGI\n\nuWSGI will be installed from its sources with the support for multiple languages, then a plugin will be built for each language to be supported:\n- get uwsgi latest sources from [here](http://uwsgi-docs.readthedocs.io/en/latest/Download.html);\n- extract the files in a local directory;\n- open a terminal and `cd` into the uwsgi sources directory;\n- build the uwsgi binary:\n```sh\nmake nolang\n```\n\n- generate the plugins, being sure to already have installed, for each plugin, its corresponding binary (e.g. `python3.5` or `python27`). In the case of various Python versions, execute:\n```sh\nPYTHON=python2.7 ./uwsgi --build-plugin \"plugins/python python27\"\nPYTHON=python3.6 ./uwsgi --build-plugin \"plugins/python python36\"\n```\n- create a local directory where you intend to collect all your uWSGI plugins (e.g. `~/uwsgi/plugins/`);\n- copy **all** the plugins to the directory you have just created:\n```sh\ncp python27_plugin.so ~/uwsgi/plugins/\ncp python36_plugin.so ~/uwsgi/plugins/\n```\n- install the compiled uWSGI binary, e.g.:\n```sh\ncp uwsgi /usr/local/bin/\n```\n\n### Bonjour\n\nThis part is only meant for macOS and makes it possible to assign a custom domain to each project (e.g. `my_new_project.local/`):\n- compile the bonjour uWSGI plugin:\n\n```sh\nuwsgi --build-plugin https://github.com/unbit/uwsgi-bonjour\n```\n- copy the plugin to the uWSGI plugins directory:\n\n```sh\ncp bonjour_plugin.so ~/uwsgi/plugins/\n```\nBonjour works thanks to Unbit uwsgi-bonjour, for further information check [here](https://github.com/unbit/uwsgi-bonjour).\n\n### Emperor\n\nFor more information on uWSGI _emperor_ mode refer to the [official documentation](http://uwsgi-docs.readthedocs.io/en/latest/Emperor.html). Before configuring uWSGI:\n- create a directory where to collect all the projects .ini configuration files (e.g. `~/uwsgi/vassals/`);\n\nProvided `emperor.ini` contains a sample configuration to run the uWSGI server in _emperor_ mode. Customize it with the paths to your vassals and plugins directories and to the emperor log file, plus any other setting/option you wish to run the emperor with. Then:\n- move the customised emperor configuration file to a convenient location:\n\n```sh\ncp emperor.ini ~/uwsgi/\n```\nBe careful not to put the emperor configuration file into the vassals configuration files directory. Also note that the provided configuration file sets the emperor to use port 80, which must be available for the server to work.\n\n### Vassals\n\nThe emperor needs to be told the language of each project, therefore make sure to indicate the corresponding plugin in each vassal configuration file:\n\n```INI\nplugin = python35\n```\n\n##### Bonjour (macOS)\n\nIn order to assign a custom domain to a project (e.g. `my_new_project.local/`), also include the following lines in the corresponding vassal configuration file:\n\n```INI\nplugin = bonjour\nbonjour-register = name=%(project_name).local,cname=localhost\nsocket = 127.0.0.1:0\nsubscribe-to = 127.0.0.1:5005:%(project_name).local\n```\n\n# Execution\n\nThe emperor can now be launched both manually and automatically.\n\n### Manual\n\nThis is straightforward, just launch uWSGI as superuser and with the emperor configuration file:\n\n```sh\nsudo uwsgi ~/uwsgi/emperor.ini\n```\n\n### Automatic (macOS)\n\nProvided `it.unbit.uwsgi.emperor.plist` is a sample property list file that instructs `launchd` to run the emperor as a daemon. Customize it with the paths to your `uwsgi` binary (e.g. `/usr/local/bin/uwsgi`) and to the configuration file (`~/uwsgi/emperor.ini`). Then move, as superuser, the property list file to its location, load it and start it:\n\n```sh\nsudo cp it.unbit.uwsgi.emperor.plist /Library/LaunchDaemons/\nsudo launchctl load /Library/LaunchDaemons/it.unbit.uwsgi.emperor.plist\nsudo launchctl start /Library/LaunchDaemons/it.unbit.uwsgi.emperor.plist\n```\n\nIn case you need to stop the daemon:\n\n```sh\nsudo launchctl stop /Library/LaunchDaemons/it.unbit.uwsgi.emperor.plist\n```\n\nIn case you need to unload the daemon:\n\n```sh\nsudo launchctl unload /Library/LaunchDaemons/it.unbit.uwsgi.emperor.plist\n```\n\n\n# SSL/HTTPS support on macOS Mojave - EXPERIMENTAL\n\nIn order to enable SSL/HTTPS support, uWSGI must be compiled accordingly.\nTherefore, any existing uWSGI installation/setup must be deleted and\ncreated from scratch.\n\n1. Make sure `openssl` is installed and updated (e.g. via `brew`):\n\n    ```sh\n    brew install openssl \u0026\u0026 brew upgrade openssl\n    ```\n\n2. Download uWSGI source files and build like this:\n\n    ```sh\n    CFLAGS=\"-I/usr/local/opt/openssl/include\" LDFLAGS=\"-L/usr/local/opt/openssl/lib\" UWSGI_PROFILE_OVERRIDE=ssl=true make nolang\n    ```\n\n3. Delete and recreate, with the new `uwsgi` binary, all existing plugins\n(refer to the instructions above).\n\n4. Generate certificate files in a convenient location:\n    ```sh\n    openssl genrsa -out my_cert.key 2048\n    openssl req -new -key my_cert.key -out my_cert.csr\n    openssl x509 -req -days 365 -in my_cert.csr -signkey my_cert.key -out my_cert.crt\n    ```\n\n5. Add the following line to `emperor.ini`:\n\n    ```ini\n    https = :443,path-to-my_cert.crt,path-to-my_cert.key\n    ```\n\n6. If the following error occurs (e.g. when using the `requests` Python package):\n\n    ```\n    +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called.```\n    ```\n \n     add a line to `emperor.ini` with:\n \n    ```ini\n    env = OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES\n    ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F20tab%2Fuwsgi-emperor-mode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F20tab%2Fuwsgi-emperor-mode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F20tab%2Fuwsgi-emperor-mode/lists"}