@@ -224,8 +224,6 @@ async def main(self):
224
224
True ,
225
225
url = f"{ get_ip_address ()} " if open_service else None ,
226
226
)
227
- if open_service :
228
- run_service ()
229
227
except asyncio .exceptions .CancelledError :
230
228
print ("Update cancelled!" )
231
229
@@ -253,14 +251,23 @@ def scheduled_task():
253
251
254
252
255
253
def run_service ():
256
- if not os .environ .get ("GITHUB_ACTIONS" ):
257
- ip_address = get_ip_address ()
258
- print (f"📄 Result detail: { ip_address } /result" )
259
- print (f"📄 Log detail: { ip_address } /log" )
260
- print (f"✅ You can use this url to watch IPTV 📺: { ip_address } " )
261
- app .run (host = "0.0.0.0" , port = 8000 )
254
+ try :
255
+ if not os .environ .get ("GITHUB_ACTIONS" ):
256
+ ip_address = get_ip_address ()
257
+ print (f"📄 Result detail: { ip_address } /result" )
258
+ print (f"📄 Log detail: { ip_address } /log" )
259
+ print (f"✅ You can use this url to watch IPTV 📺: { ip_address } " )
260
+ app .run (host = "0.0.0.0" , port = 8000 )
261
+ except Exception as e :
262
+ print (f"❌ Service start failed: { e } " )
262
263
263
264
264
265
if __name__ == "__main__" :
265
- if len (sys .argv ) == 1 or (len (sys .argv ) > 1 and sys .argv [1 ] == "scheduled_task" ):
266
- scheduled_task ()
266
+ if len (sys .argv ) == 1 and config .open_service :
267
+ loop = asyncio .new_event_loop ()
268
+
269
+ async def run_service_async ():
270
+ loop .run_in_executor (None , run_service )
271
+
272
+ asyncio .run (run_service_async ())
273
+ scheduled_task ()
0 commit comments