|
@@ -4,7 +4,7 @@ import signal
|
|
import ipaddress
|
|
import ipaddress
|
|
import importlib
|
|
import importlib
|
|
|
|
|
|
-import bjoern # Does not work for Windows
|
|
|
|
|
|
+import bjoern # Does not work for Windows
|
|
|
|
|
|
from . import parser, utils
|
|
from . import parser, utils
|
|
|
|
|
|
@@ -15,7 +15,7 @@ def main():
|
|
args = parser.parse_args()
|
|
args = parser.parse_args()
|
|
|
|
|
|
if args.workers < 1:
|
|
if args.workers < 1:
|
|
- raise AttributeError(f'Workers must not be less than 1')
|
|
|
|
|
|
+ raise AttributeError('Workers must not be less than 1')
|
|
|
|
|
|
sys.path.insert(1, os.getcwd())
|
|
sys.path.insert(1, os.getcwd())
|
|
|
|
|
|
@@ -24,10 +24,13 @@ def main():
|
|
try:
|
|
try:
|
|
module_path, attr = full_module_path.split(':')
|
|
module_path, attr = full_module_path.split(':')
|
|
except ValueError:
|
|
except ValueError:
|
|
- raise AttributeError(f'No module attribute specified in "{full_module_path}"')
|
|
|
|
|
|
+ raise AttributeError(
|
|
|
|
+ f'No module attribute specified in "{full_module_path}"'
|
|
|
|
+ )
|
|
|
|
|
|
if not attr:
|
|
if not attr:
|
|
- raise AttributeError(f'Module attribute cannot be empty ({full_module_path})')
|
|
|
|
|
|
+ raise AttributeError(
|
|
|
|
+ f'Module attribute cannot be empty ({full_module_path})')
|
|
|
|
|
|
module = importlib.import_module(module_path)
|
|
module = importlib.import_module(module_path)
|
|
|
|
|
|
@@ -53,6 +56,9 @@ def main():
|
|
|
|
|
|
print('Bjoern server has started')
|
|
print('Bjoern server has started')
|
|
|
|
|
|
|
|
+ if not port:
|
|
|
|
+ utils.set_socket_permissions(host)
|
|
|
|
+
|
|
pids = utils.create_workers(workers)
|
|
pids = utils.create_workers(workers)
|
|
|
|
|
|
if not pids:
|
|
if not pids:
|
|
@@ -63,7 +69,7 @@ def main():
|
|
except KeyboardInterrupt:
|
|
except KeyboardInterrupt:
|
|
pass
|
|
pass
|
|
|
|
|
|
- exit()
|
|
|
|
|
|
+ sys.exit()
|
|
|
|
|
|
try:
|
|
try:
|
|
# Wait for the first worker to exit. They should never exit!
|
|
# Wait for the first worker to exit. They should never exit!
|
|
@@ -77,7 +83,7 @@ def main():
|
|
for pid in pids:
|
|
for pid in pids:
|
|
os.kill(pid, signal.SIGINT)
|
|
os.kill(pid, signal.SIGINT)
|
|
|
|
|
|
- exit(1)
|
|
|
|
|
|
+ sys.exit(1)
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|