# Easy Deployment
Easy deployment tool for Python application. There are mainly two parts:
- Create a virtual environment (Optional).
- Install your application as a service.
Deploy your application with one command!
## Install
It's recommended that you install this package in the **Global Python Environment**.
```
pip install ezd
```
On Windows, be careful if you want to uninstall this package. Make sure all services created with this tool are removed.
## Usage
### Config file
Run `ezd init` to create a config file named `deploy.json`.
```json
{
"env": {
"name": "venv"
},
"service": {
"name": "",
"cmd": [],
"display": "",
"description": ""
}
}
```
A list of full parameters:
| Parameter | Type | Description | Windows | Linux |
|---------------------------|--------------|----------------------------------------------------------------------------------------------------|--------------------|--------------------|
| env.name | string | The name of virtual environment. | :heavy_check_mark: | :heavy_check_mark: |
| env.lookup | string | Offline package lookup directory used by pip. | :heavy_check_mark: | :heavy_check_mark: |
| env.local | string | A directory contains local package file. | :heavy_check_mark: | :heavy_check_mark: |
| env.requirement | bool | Whether to install dependencies in `requirements.txt`. Default is `true`. | :heavy_check_mark: | :heavy_check_mark: |
| service.name | string | The name of service. | :heavy_check_mark: | :heavy_check_mark: |
| service.cmd | list[string] | The command line to be executed. | :heavy_check_mark: | :heavy_check_mark: |
| service.display | string | Display name of service. | :heavy_check_mark: | :x: |
| service.description | string | Description of service. | :heavy_check_mark: | :heavy_check_mark: |
| service.start | string | Start type of service (demand/auto/boot/disabled/system). Default is `auto`. | :heavy_check_mark: | :heavy_check_mark: |
| service.restart | int | Restart delay (seconds) when service failed. Default is `30`. | :heavy_check_mark: | :heavy_check_mark: |
| service.restart_policy | string | Configures whether the service shall be restarted when the service exits. Default is `on-failure`. | :x: | :heavy_check_mark: |
| service.runtime_max_sec | int | Configures a maximum time for the service to run. Default is `0`. | :x: | :heavy_check_mark: |
| service.working_directory | string | Configures the working directory of the service. Default is `.`. | :heavy_check_mark: | :heavy_check_mark: |
| service.deps | list[string] | Dependencies of service. | :heavy_check_mark: | :heavy_check_mark: |
| service.interactive | bool | Run service in interactive mode. Default is `false`. | :heavy_check_mark: | :x: |
| service.user | string | Run service with given user. | :heavy_check_mark: | :heavy_check_mark: |
| service.password | string | Password of the user. | :heavy_check_mark: | :x: |
| service.delayed | bool | Delayed start of service. | :heavy_check_mark: | :x: |
### Commands
Run `ezd -h` to see all commands.
```
usage: ezd [-h] command
Easy Deployment Tool
positional arguments:
command Command <init|deploy|install|uninstall|start|stop>
options:
-h, --help show this help message and exit
--config CONFIG config file
```
Available commands:
| Command | Description |
|-----------|---------------------------------------------------------------|
| init | Create an example config file `deploy.json`. |
| deploy | Create virtual environment and install dependencies. |
| install | Install a service (Automatically run `deploy` command first). |
| uninstall | Remove service (Automatically run `stop` command first). |
| start | Start service. |
| stop | Stop service. |
### Update config
#### Upgrade or install packages
If you need to upgrade or install packages, just edit the `requirements.txt` file and follow the steps below:
1. Stop the service
```shell
ezd stop
```
2. Deploy new packages
```shell
ezd deploy
```
3. Start the service
```shell
ezd start
```
#### Update service
If you update the service settings of the config file, you must `uninstall` the old service first.
1. Uninstall the service
```shell
ezd uninstall
```
2. Install service
```shell
ezd install
```
3. Start the service
```shell
ezd start
```
## Examples
### Jupyter notebook
Create a new `nb` directory and start working in it.
```shell
cd nb
echo notebook > requirements.txt
ezd init
```
The `deploy.json` file looks like this:
```json
{
"env": {
"name": "venv"
},
"service": {
"name": "notebook",
"cmd": [
"jupyter-notebook.exe"
],
"display": "Jupyter Notebook",
"description": "Jupyter Notebook Service"
}
}
```
We are ready to deploy now.
```shell
ezd install
ezd start
```
You can now visit http://localhost:8888/ to confirm jupyter notebook is running.
### Ping test
Create a new `pingtest` directory and start working in it.
```shell
cd pingtest
ezd init
```
For non-python project, we can omit virtual environment since we don't need it. The `deploy.json` file looks like this:
```json
{
"service": {
"name": "pingtest",
"cmd": [
"ping",
"-t",
"1.1.1.1"
],
"display": "Ping it",
"description": "A ping test service"
}
}
```
Deploy now!
```shell
ezd install
ezd start
```
Let's confirm ping is running:
```shell
$ tasklist | findstr PING
PING.EXE 19564 Services 0 4,540 K
```
Raw data
{
"_id": null,
"home_page": "https://github.com/koho/ezd",
"name": "ezd",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.5",
"maintainer_email": "",
"keywords": "deploy,service,python-script,cli",
"author": "Gerhard Tan",
"author_email": "gwohau.tan@gmail.com",
"download_url": "",
"platform": "any",
"description": "# Easy Deployment\r\n\r\nEasy deployment tool for Python application. There are mainly two parts:\r\n\r\n- Create a virtual environment (Optional).\r\n- Install your application as a service.\r\n\r\nDeploy your application with one command!\r\n\r\n## Install\r\n\r\nIt's recommended that you install this package in the **Global Python Environment**.\r\n\r\n```\r\npip install ezd\r\n```\r\n\r\nOn Windows, be careful if you want to uninstall this package. Make sure all services created with this tool are removed.\r\n\r\n## Usage\r\n\r\n### Config file\r\n\r\nRun `ezd init` to create a config file named `deploy.json`.\r\n\r\n```json\r\n{\r\n \"env\": {\r\n \"name\": \"venv\"\r\n },\r\n \"service\": {\r\n \"name\": \"\",\r\n \"cmd\": [],\r\n \"display\": \"\",\r\n \"description\": \"\"\r\n }\r\n}\r\n```\r\n\r\nA list of full parameters:\r\n\r\n| Parameter | Type | Description | Windows | Linux |\r\n|---------------------------|--------------|----------------------------------------------------------------------------------------------------|--------------------|--------------------|\r\n| env.name | string | The name of virtual environment. | :heavy_check_mark: | :heavy_check_mark: |\r\n| env.lookup | string | Offline package lookup directory used by pip. | :heavy_check_mark: | :heavy_check_mark: |\r\n| env.local | string | A directory contains local package file. | :heavy_check_mark: | :heavy_check_mark: |\r\n| env.requirement | bool | Whether to install dependencies in `requirements.txt`. Default is `true`. | :heavy_check_mark: | :heavy_check_mark: |\r\n| service.name | string | The name of service. | :heavy_check_mark: | :heavy_check_mark: |\r\n| service.cmd | list[string] | The command line to be executed. | :heavy_check_mark: | :heavy_check_mark: |\r\n| service.display | string | Display name of service. | :heavy_check_mark: | :x: |\r\n| service.description | string | Description of service. | :heavy_check_mark: | :heavy_check_mark: |\r\n| service.start | string | Start type of service (demand/auto/boot/disabled/system). Default is `auto`. | :heavy_check_mark: | :heavy_check_mark: |\r\n| service.restart | int | Restart delay (seconds) when service failed. Default is `30`. | :heavy_check_mark: | :heavy_check_mark: |\r\n| service.restart_policy | string | Configures whether the service shall be restarted when the service exits. Default is `on-failure`. | :x: | :heavy_check_mark: |\r\n| service.runtime_max_sec | int | Configures a maximum time for the service to run. Default is `0`. | :x: | :heavy_check_mark: |\r\n| service.working_directory | string | Configures the working directory of the service. Default is `.`. | :heavy_check_mark: | :heavy_check_mark: |\r\n| service.deps | list[string] | Dependencies of service. | :heavy_check_mark: | :heavy_check_mark: |\r\n| service.interactive | bool | Run service in interactive mode. Default is `false`. | :heavy_check_mark: | :x: |\r\n| service.user | string | Run service with given user. | :heavy_check_mark: | :heavy_check_mark: |\r\n| service.password | string | Password of the user. | :heavy_check_mark: | :x: |\r\n| service.delayed | bool | Delayed start of service. | :heavy_check_mark: | :x: |\r\n\r\n### Commands\r\n\r\nRun `ezd -h` to see all commands.\r\n\r\n```\r\nusage: ezd [-h] command\r\n\r\nEasy Deployment Tool\r\n\r\npositional arguments:\r\n command Command <init|deploy|install|uninstall|start|stop>\r\n\r\noptions:\r\n -h, --help show this help message and exit\r\n --config CONFIG config file\r\n```\r\n\r\nAvailable commands:\r\n\r\n| Command | Description |\r\n|-----------|---------------------------------------------------------------|\r\n| init | Create an example config file `deploy.json`. |\r\n| deploy | Create virtual environment and install dependencies. |\r\n| install | Install a service (Automatically run `deploy` command first). |\r\n| uninstall | Remove service (Automatically run `stop` command first). |\r\n| start | Start service. |\r\n| stop | Stop service. |\r\n\r\n### Update config\r\n\r\n#### Upgrade or install packages\r\n\r\nIf you need to upgrade or install packages, just edit the `requirements.txt` file and follow the steps below:\r\n\r\n1. Stop the service\r\n\r\n ```shell\r\n ezd stop\r\n ```\r\n\r\n2. Deploy new packages\r\n\r\n ```shell\r\n ezd deploy\r\n ```\r\n\r\n3. Start the service\r\n\r\n ```shell\r\n ezd start\r\n ```\r\n\r\n#### Update service\r\n\r\nIf you update the service settings of the config file, you must `uninstall` the old service first.\r\n\r\n1. Uninstall the service\r\n\r\n ```shell\r\n ezd uninstall\r\n ```\r\n\r\n2. Install service\r\n\r\n ```shell\r\n ezd install\r\n ```\r\n\r\n3. Start the service\r\n\r\n ```shell\r\n ezd start\r\n ```\r\n\r\n## Examples\r\n\r\n### Jupyter notebook\r\n\r\nCreate a new `nb` directory and start working in it.\r\n\r\n```shell\r\ncd nb\r\necho notebook > requirements.txt\r\nezd init\r\n```\r\n\r\nThe `deploy.json` file looks like this:\r\n\r\n```json\r\n{\r\n \"env\": {\r\n \"name\": \"venv\"\r\n },\r\n \"service\": {\r\n \"name\": \"notebook\",\r\n \"cmd\": [\r\n \"jupyter-notebook.exe\"\r\n ],\r\n \"display\": \"Jupyter Notebook\",\r\n \"description\": \"Jupyter Notebook Service\"\r\n }\r\n}\r\n```\r\n\r\nWe are ready to deploy now.\r\n\r\n```shell\r\nezd install\r\nezd start\r\n```\r\n\r\nYou can now visit http://localhost:8888/ to confirm jupyter notebook is running.\r\n\r\n### Ping test\r\n\r\nCreate a new `pingtest` directory and start working in it.\r\n\r\n```shell\r\ncd pingtest\r\nezd init\r\n```\r\n\r\nFor non-python project, we can omit virtual environment since we don't need it. The `deploy.json` file looks like this:\r\n\r\n```json\r\n{\r\n \"service\": {\r\n \"name\": \"pingtest\",\r\n \"cmd\": [\r\n \"ping\",\r\n \"-t\",\r\n \"1.1.1.1\"\r\n ],\r\n \"display\": \"Ping it\",\r\n \"description\": \"A ping test service\"\r\n }\r\n}\r\n```\r\n\r\nDeploy now!\r\n\r\n```shell\r\nezd install\r\nezd start\r\n```\r\n\r\nLet's confirm ping is running:\r\n\r\n```shell\r\n$ tasklist | findstr PING\r\nPING.EXE 19564 Services 0 4,540 K\r\n```\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Easy Deployment Tool",
"version": "0.3.2",
"project_urls": {
"Bug Tracker": "https://github.com/koho/ezd/issues",
"Homepage": "https://github.com/koho/ezd"
},
"split_keywords": [
"deploy",
"service",
"python-script",
"cli"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8f1c7e061b4d3387f0862b267ddd42ec46217031e560d92cd307342f9155f1c9",
"md5": "8dd60c28c61011ade0c71d11e9f24d21",
"sha256": "31e27da3eafeffca9fd7d65800e02e14032cf87e39a0bfa35b143aaa43c19dbe"
},
"downloads": -1,
"filename": "ezd-0.3.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8dd60c28c61011ade0c71d11e9f24d21",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.5",
"size": 8856,
"upload_time": "2024-01-10T16:31:07",
"upload_time_iso_8601": "2024-01-10T16:31:07.169435Z",
"url": "https://files.pythonhosted.org/packages/8f/1c/7e061b4d3387f0862b267ddd42ec46217031e560d92cd307342f9155f1c9/ezd-0.3.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-10 16:31:07",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "koho",
"github_project": "ezd",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "ezd"
}