diff --git a/platypush/__init__.py b/platypush/__init__.py index f4e9ecb921..ede8fee4bc 100644 --- a/platypush/__init__.py +++ b/platypush/__init__.py @@ -5,12 +5,13 @@ Platypush .. license: MIT """ -from .app import Application, main +from .app import Application from .config import Config from .context import get_backend, get_bus, get_plugin from .message.event import Event from .message.request import Request from .message.response import Response +from .runner import main __author__ = 'Fabio Manganiello ' diff --git a/platypush/cli.py b/platypush/cli.py index 81bc4c35f4..9864c16be0 100644 --- a/platypush/cli.py +++ b/platypush/cli.py @@ -2,6 +2,7 @@ import argparse from typing import Sequence from platypush.bus.redis import RedisBus +from platypush.utils import get_default_pid_file def parse_cmdline(args: Sequence[str]) -> argparse.Namespace: @@ -61,10 +62,10 @@ def parse_cmdline(args: Sequence[str]) -> argparse.Namespace: '-P', dest='pidfile', required=False, - default=None, + default=get_default_pid_file(), help="File where platypush will " + "store its PID, useful if you're planning to " - + "integrate it in a service", + + f"integrate it in a service (default: {get_default_pid_file()})", ) parser.add_argument( diff --git a/platypush/utils/__init__.py b/platypush/utils/__init__.py index fd80f1e9e6..a164c982b0 100644 --- a/platypush/utils/__init__.py +++ b/platypush/utils/__init__.py @@ -14,6 +14,7 @@ import socket import ssl import urllib.request from threading import Lock as TLock +from tempfile import gettempdir from typing import Generator, Optional, Tuple, Union from dateutil import parser, tz @@ -625,4 +626,11 @@ def get_lock( lock.release() +def get_default_pid_file() -> str: + """ + Get the default PID file path. + """ + return os.path.join(gettempdir(), 'platypush.pid') + + # vim:sw=4:ts=4:et: