python-dmon 0.2.3__tar.gz → 0.2.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: python-dmon
3
- Version: 0.2.3
3
+ Version: 0.2.4
4
4
  Summary: A lightweight, cross-platform daemon manager that runs any command as a background process.
5
5
  Keywords: python-dmon,dmon,daemon,background,detach,process management
6
6
  Author: Atomie CHEN
@@ -38,6 +38,8 @@ It is a Python-based and more powerful successor to the [handy-backend shell scr
38
38
  - 🧩 **Flexible tasks:** Tasks can be configured in `pyproject.toml` or `dmon.yaml`; or run ad-hoc commands directly.
39
39
  - 🪵 **Logging & log rotation:** Automatically manage log files to prevent uncontrolled growth.
40
40
 
41
+ ![dmon-demo-gif](https://github.com/user-attachments/assets/9bae2f46-5ef4-4784-aced-18d573204efc)
42
+
41
43
 
42
44
  ## Installation
43
45
 
@@ -84,14 +86,16 @@ Create a `dmon.yaml` file:
84
86
 
85
87
  ```yaml
86
88
  tasks:
87
- app: ["python", "-u", "server.py"]
89
+ app: ["python", "-u", "server.py"] # option 1: exec form
90
+ # app: "python -u server.py" # option 2: shell string
88
91
  ```
89
92
 
90
93
  Or add to your `pyproject.toml`:
91
94
 
92
95
  ```toml
93
96
  [tool.dmon.tasks]
94
- app = ["python", "-u", "server.py"]
97
+ app = ["python", "-u", "server.py"] # option 1: exec form
98
+ # app = "python -u server.py" # option 2: shell string
95
99
  ```
96
100
 
97
101
  Commands can be a single string (run in shell), or list of strings (exec form).
@@ -20,6 +20,8 @@ It is a Python-based and more powerful successor to the [handy-backend shell scr
20
20
  - 🧩 **Flexible tasks:** Tasks can be configured in `pyproject.toml` or `dmon.yaml`; or run ad-hoc commands directly.
21
21
  - 🪵 **Logging & log rotation:** Automatically manage log files to prevent uncontrolled growth.
22
22
 
23
+ ![dmon-demo-gif](https://github.com/user-attachments/assets/9bae2f46-5ef4-4784-aced-18d573204efc)
24
+
23
25
 
24
26
  ## Installation
25
27
 
@@ -66,14 +68,16 @@ Create a `dmon.yaml` file:
66
68
 
67
69
  ```yaml
68
70
  tasks:
69
- app: ["python", "-u", "server.py"]
71
+ app: ["python", "-u", "server.py"] # option 1: exec form
72
+ # app: "python -u server.py" # option 2: shell string
70
73
  ```
71
74
 
72
75
  Or add to your `pyproject.toml`:
73
76
 
74
77
  ```toml
75
78
  [tool.dmon.tasks]
76
- app = ["python", "-u", "server.py"]
79
+ app = ["python", "-u", "server.py"] # option 1: exec form
80
+ # app = "python -u server.py" # option 2: shell string
77
81
  ```
78
82
 
79
83
  Commands can be a single string (run in shell), or list of strings (exec form).
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "python-dmon"
3
- version = "0.2.3"
3
+ version = "0.2.4"
4
4
  description = "A lightweight, cross-platform daemon manager that runs any command as a background process."
5
5
  readme = "README.md"
6
6
  authors = [
@@ -121,9 +121,9 @@ def validate_task(task, name: str) -> DmonTaskConfig:
121
121
  ret.log_rotate = task["log_rotate"]
122
122
 
123
123
  if "log_max_size" in task:
124
- if not isinstance(task["log_max_size"], int) or task["log_max_size"] <= 0:
124
+ if not isinstance(task["log_max_size"], (int, float)) or task["log_max_size"] <= 0:
125
125
  raise TypeError(
126
- f"Task '{name}' 'log_max_size' field must be a positive integer"
126
+ f"Task '{name}' 'log_max_size' field must be a positive number"
127
127
  )
128
128
  ret.log_max_size = task["log_max_size"]
129
129
 
@@ -136,11 +136,11 @@ def validate_task(task, name: str) -> DmonTaskConfig:
136
136
 
137
137
  if "rotate_log_max_size" in task:
138
138
  if (
139
- not isinstance(task["rotate_log_max_size"], int)
139
+ not isinstance(task["rotate_log_max_size"], (int, float))
140
140
  or task["rotate_log_max_size"] <= 0
141
141
  ):
142
142
  raise TypeError(
143
- f"Task '{name}' 'rotate_log_max_size' field must be a positive integer"
143
+ f"Task '{name}' 'rotate_log_max_size' field must be a positive number"
144
144
  )
145
145
  ret.rotate_log_max_size = task["rotate_log_max_size"]
146
146
 
@@ -167,7 +167,7 @@ if __name__ == "__main__":
167
167
  parser.add_argument(
168
168
  "--max-log-size",
169
169
  help="Max log file size (MB); 0 for no rotation",
170
- type=int,
170
+ type=float,
171
171
  default=5,
172
172
  )
173
173
  parser.add_argument(
@@ -178,15 +178,15 @@ if __name__ == "__main__":
178
178
  parser.add_argument(
179
179
  "--max-rotate-log-size",
180
180
  help="Max file size (MB) for this rotation log; 0 for no rotation",
181
- type=int,
181
+ type=float,
182
182
  default=5,
183
183
  )
184
184
  args = parser.parse_args()
185
185
  main(
186
186
  " ".join(args.command) if args.shell else args.command,
187
187
  args.log_path,
188
- args.max_log_size * 1024 * 1024,
188
+ int(args.max_log_size * 1024 * 1024),
189
189
  args.rotate_log_path,
190
- args.max_rotate_log_size * 1024 * 1024,
190
+ int(args.max_rotate_log_size * 1024 * 1024),
191
191
  )
192
192
  logger.info("Process finished.")
@@ -31,11 +31,11 @@ class DmonTaskConfig:
31
31
  """Path to log file"""
32
32
  log_rotate: bool = False
33
33
  """Whether to rotate log file"""
34
- log_max_size: int = 5
34
+ log_max_size: float = 5
35
35
  """Size in MB to rotate log file"""
36
36
  rotate_log_path: str = ""
37
37
  """Path to rotation log file"""
38
- rotate_log_max_size: int = 5
38
+ rotate_log_max_size: float = 5
39
39
  """Size in MB to rotation log file"""
40
40
  meta_path: str = ""
41
41
  """Path to meta file"""
File without changes