Restructure as runnable Python module
Convert email_forwarder.py to a package with __main__.py for module execution. Update systemd service to use -m email_forwarder. Configure pyproject.toml to exclude state/ from packaging. Changes: - Create email_forwarder/ package with __init__.py and __main__.py - Move main script to email_forwarder/email_forwarder.py - Update ExecStart to python -m email_forwarder - Add setuptools config to exclude state/ directory
This commit is contained in:
parent
02f6461cbc
commit
c96bd8ed71
6 changed files with 11 additions and 3 deletions
|
|
@ -38,5 +38,5 @@ This will set up the virtual environment, systemd services, and provide post-ins
|
|||
## Troubleshooting
|
||||
|
||||
- Logs: `journalctl --user -u email_forwarder.service`
|
||||
- Test: `source venv/bin/activate && python email_forwarder.py`
|
||||
- Test: `source venv/bin/activate && python -m email_forwarder`
|
||||
- Timezone issues: Adjust UTC offset in script if needed.
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
Description=Email Forwarder
|
||||
|
||||
[Service]
|
||||
ExecStart=${PROJECT_DIR}/venv/bin/python ${PROJECT_DIR}/email_forwarder.py
|
||||
ExecStart=${PROJECT_DIR}/venv/bin/python -m email_forwarder
|
||||
ExecStartPost=/usr/bin/curl -fsS --retry 3 ${UPTIME_SUCCESS_URL}
|
||||
OnFailure=email_forwarder-fail-notify.service
|
||||
|
||||
|
|
|
|||
1
email_forwarder/__init__.py
Normal file
1
email_forwarder/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
# Email Forwarder Package
|
||||
4
email_forwarder/__main__.py
Normal file
4
email_forwarder/__main__.py
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
from .email_forwarder import main
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -7,4 +7,7 @@ version = "0.1.0"
|
|||
dependencies = [
|
||||
"imap-tools",
|
||||
"python-dotenv",
|
||||
]
|
||||
]
|
||||
|
||||
[tool.setuptools.packages.find]
|
||||
exclude = ["state"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue