diff --git a/py4web/core.py b/py4web/core.py index ce313e138..75e5bd0dc 100644 --- a/py4web/core.py +++ b/py4web/core.py @@ -2048,7 +2048,7 @@ def run(**kwargs): 'You have not set a dashboard password. Run "%s set_password" to do so.' % PY4WEB_CMD ) - elif "_dashboard" in Reloader.ROUTES and (not kwargs['host'].startswith('unix:')) : + elif "_dashboard" in Reloader.ROUTES and (not kwargs['host'].startswith('unix:/')) : click.echo( f"Dashboard is at: http{'s' if kwargs.get('ssl_cert', None) else ''}://{kwargs['host']}:{kwargs['port']}/_dashboard" ) diff --git a/py4web/server_adapters.py b/py4web/server_adapters.py index 33955838e..0de455c57 100644 --- a/py4web/server_adapters.py +++ b/py4web/server_adapters.py @@ -134,10 +134,16 @@ def os_cmd (run_cmd ): if host.startswith('unix:/'): socket_path = host[5:] if os.path.exists(socket_path): - os_cmd ("ps -ef | head -1; ps -ef | grep py4web | grep -v grep") - os_cmd (f"ls -alFi {socket_path}") - print (f"reopen {socket_path}") - print (f'=== gunicorn listening at: {host} ===') + if port == 0: + os_cmd (f"ls -alFi {socket_path}") + sys.exit(f"can't run gunicorn: {socket_path} exists") + elif port == 1: + os_cmd ("ps -ef | head -1; ps -ef | grep py4web | grep -v grep") + os_cmd (f"ls -alFi {socket_path}") + os_cmd (f"lsof -w {socket_path}") + elif port == 8000: + pass + print (f'gunicorn listening at: {host}') return s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) @@ -145,7 +151,8 @@ def os_cmd (run_cmd ): s.bind((host, int(port) )) except socket.error as e: if e.errno == errno.EADDRINUSE: - os_cmd( f"command -v lsof >/dev/null 2>&1 && ps aux | grep py4web && lsof -nPi:{port}" ) + os_cmd( f"command -v lsof >/dev/null 2>&1 && ps -ef | head -1; ps -ef |" + f" grep py4web | grep -v grep && lsof -nPi:{port}" ) sys.exit(f"{host}:{port} is already in use") else: sys.exit(f"{e}\n{host}:{port} cannot be acessed")