Spaces:
Runtime error
Runtime error
Commit
·
7c6f5fb
1
Parent(s):
2e7c76e
update: robust restart
Browse files- app/entry.py +16 -9
app/entry.py
CHANGED
|
@@ -6,17 +6,24 @@ from app.handler import handler
|
|
| 6 |
|
| 7 |
|
| 8 |
def entry():
|
| 9 |
-
os.
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
demo.launch()
|
| 20 |
|
| 21 |
if __name__ == '__main__':
|
| 22 |
entry()
|
|
|
|
| 6 |
|
| 7 |
|
| 8 |
def entry():
|
| 9 |
+
REPO_ROOT = str(os.path.join(os.path.dirname(__file__), '..'))
|
| 10 |
+
os.system(f'touch {REPO_ROOT}/server_up')
|
| 11 |
+
os.system('lsof -i :7860 | grep LISTEN | awk \'{print $2}\' | xargs kill')
|
| 12 |
|
| 13 |
+
try:
|
| 14 |
+
demo = gr.Interface(
|
| 15 |
+
fn = handler,
|
| 16 |
+
inputs = get_inputs_components(),
|
| 17 |
+
outputs = get_outputs_components(),
|
| 18 |
+
examples = get_examples(),
|
| 19 |
+
description = get_desc(),
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
demo.launch()
|
| 23 |
+
except Exception as e:
|
| 24 |
+
print(f'Error: {str(e)}')
|
| 25 |
+
os.system(f'rm {REPO_ROOT}/server_up')
|
| 26 |
|
|
|
|
| 27 |
|
| 28 |
if __name__ == '__main__':
|
| 29 |
entry()
|