mirror of
https://github.com/bugsink/bugsink.git
synced 2026-01-06 05:10:15 -06:00
runssnappea as a separate command (for e.g. ps)
This commit is contained in:
31
bugsink/scripts/runsnappea.py
Normal file
31
bugsink/scripts/runsnappea.py
Normal file
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env python
|
||||
"""A copy of manage.py from the bugsink project, but with sys.argv[1] inserted as 'runsnappea'; when run this way the
|
||||
script shows up with a meaningful name in `ps` and other such tools.
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
# To maintain equivalent behavior to `python manage.py` / `python -m bugsink.scripts.manage` when running this
|
||||
# script as `bugsink-manage` we need to add the current directory to sys.path. Otherwise the Django settings module
|
||||
# will not be found if it is in the current directory.
|
||||
cwd = os.getcwd()
|
||||
if cwd not in sys.path:
|
||||
sys.path.insert(0, cwd)
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'bugsink_conf')
|
||||
try:
|
||||
from django.core.management import execute_from_command_line
|
||||
except ImportError as exc:
|
||||
raise ImportError(
|
||||
"Couldn't import Django. Are you sure it's installed and "
|
||||
"available on your PYTHONPATH environment variable? Did you "
|
||||
"forget to activate a virtual environment?"
|
||||
) from exc
|
||||
sys.argv = sys.argv[:1] + ['runsnappea'] + sys.argv[1:]
|
||||
execute_from_command_line(sys.argv)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -421,7 +421,7 @@ Group=bugsink
|
||||
Environment="PYTHONUNBUFFERED=1"
|
||||
RuntimeDirectory=gunicorn
|
||||
WorkingDirectory=/home/bugsink
|
||||
ExecStart=/home/bugsink/venv/bin/bugsink-manage runsnappea
|
||||
ExecStart=/home/bugsink/venv/bin/bugsink-runsnappea
|
||||
ExecReload=/bin/kill -s HUP $MAINPID
|
||||
KillMode=mixed
|
||||
TimeoutStopSec=5
|
||||
|
||||
@@ -23,6 +23,7 @@ dynamic = ["version", "dependencies"]
|
||||
bugsink-show-version = "bugsink.scripts.show_version:main"
|
||||
bugsink-manage = "bugsink.scripts.manage:main"
|
||||
bugsink-create-conf = "bugsink.scripts.create_conf:main"
|
||||
bugsink-runsnappea = "bugsink.scripts.runsnappea:main"
|
||||
|
||||
[tool.setuptools]
|
||||
include-package-data = true # this is the default, but explicit is better than implicit
|
||||
|
||||
Reference in New Issue
Block a user