Skip to content

Commit

Permalink
add coffeed service command
Browse files Browse the repository at this point in the history
  • Loading branch information
tkorays committed Nov 18, 2022
1 parent b43c62d commit 4a92c91
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 41 deletions.
26 changes: 18 additions & 8 deletions Coffee/CLI/coffeed.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,10 @@ def coffee_daemon():
print(f'coffee daemon started with pid file: {PID_NAME}')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Coffee.Service.settings')
try:
from django.core.management import execute_from_command_line
from django.core.management import execute_from_command_line, ManagementUtility
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
execute_from_command_line(['manage.py', 'runserver'])
raise ImportError("Couldn't import Django.") from exc
ManagementUtility(['coffeed', 'runserver']).execute()


@click.group(help="cofd - coffee service!")
Expand All @@ -51,13 +47,27 @@ def coffeed_stop():
try:
with open(PID_NAME) as f:
os.kill(int(f.readline()), signal.SIGKILL)
print('stop success!')
except:
print('Kill process failed! No pid or no process found!')


@click.command('status', help='coffee service status')
def coffeed_status():
try:
with open(PID_NAME) as f:
os.kill(int(f.readline()), signal.SIG_DFL)
print('service is running')
except OSError:
print('service is not running')
except:
print('service is running')


coffeed.add_command(coffeed_start)
coffeed.add_command(coffeed_stop)
coffeed.add_command(coffeed_status)


if __name__ == "__main__":
coffeed()
coffeed()
16 changes: 0 additions & 16 deletions Coffee/Service/asgi.py

This file was deleted.

2 changes: 1 addition & 1 deletion Coffee/Service/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []
ALLOWED_HOSTS = ['127.0.0.1', 'localhost']


# ServiceApp definition
Expand Down
16 changes: 0 additions & 16 deletions Coffee/Service/wsgi.py

This file was deleted.

0 comments on commit 4a92c91

Please sign in to comment.