@@ -121,7 +121,7 @@ def plugin_notification(self, obj):
121121 if not isinstance (obj , notification .Notification ): raise Exception ('Notification plugin must implement the Notification interface' )
122122 self .notification = obj
123123
124- # App lifecycle hooks
124+ # App lifecycle hooks/decorators
125125 def on_create (self , func ):
126126 self ._on_create_func = func
127127 def on_start (self , func ):
@@ -192,15 +192,15 @@ def run(self):
192192
193193 emit_notification = True
194194
195- # # App lifecycle - SUCCESS
195+ # App lifecycle - SUCCESS
196196 if retcode == 0 :
197197 if self ._on_success_func :
198198 self ._on_success_func ()
199199 if not self .config ['email_on_success' ]:
200200 print ('Skipping Email Notification: Property "email_on_success" is set to FALSE.' )
201201 emit_notification = False
202- # # App lifecycle - FAIL
203- else :
202+ # App lifecycle - FAIL (<0 is for ABORT or other interrupt)
203+ elif retcode > 0 :
204204 if self ._on_fail_func :
205205 self ._on_fail_func ()
206206 if not self .config ['email_on_fail' ]:
@@ -265,7 +265,12 @@ def zip_log_files(self, exit_status):
265265
266266 try :
267267
268- suffix = 'FAILURE' if exit_status else 'SUCCESS'
268+ if exit_status == - 1 :
269+ suffix = 'ABORT'
270+ elif exit_status > 0 :
271+ suffix = 'FAILURE'
272+ else :
273+ suffix = 'SUCCESS'
269274
270275 zip_file = "{}/{}_{}_{}.zip" .format (self .config ['log_dir' ], self .config ['app_name' ], constants .EXECUTION_TIMESTAMP , suffix )
271276 print ('Zipping Up Log Files to: {}' .format (zip_file ))
@@ -356,9 +361,11 @@ def exec_from(self, id) : return self.register.exec_from(id)
356361 def exec_disable (self , id_list ) : return self .register .exec_disable (id_list )
357362
358363 def parse_args (self ):
364+ abort = False
365+
359366 opt_list = 'c:l:n:e:x:N:D:A:t:drhiv'
360367 longopt_list = [
361- 'setup' , 'help' , 'nozip' , 'interactive' ,
368+ 'setup' , 'help' , 'nozip' , 'interactive' , 'abort' ,
362369 'restart' , 'version' , 'dryrun' , 'debug' ,
363370 'preserve-context' , 'dump-logs' , 'disable-exclusive-jobs' ,
364371 'email=' , 'email-on-fail=' , 'email-on-success=' , 'ef=' , 'es=' ,
@@ -421,6 +428,8 @@ def parse_args(self):
421428 self .disable_exclusive_jobs = True
422429 elif opt in ['--exec-proc-name' ]:
423430 self ._init_params ['exec_proc_name' ] = arg
431+ elif opt == '--abort' :
432+ abort = True
424433 elif opt in ['--serde' ]:
425434 if arg .lower () == 'json' :
426435 self .plugin_serde (serde .JsonSerDe ())
@@ -441,6 +450,11 @@ def parse_args(self):
441450 raise RuntimeError ('Config file (app_profile) has not been provided' )
442451 self .config .source_config_file (self ._init_params ['config_file' ])
443452
453+ if abort :
454+ print ('Submitting ABORT signal to running job for: {}' .format (self .config ['app_name' ]))
455+ open (self .config .abort_sig_file , 'a' ).close ()
456+ sys .exit (0 )
457+
444458 # Check if restart is possible (ctllog/ctx files exist)
445459 if self ._init_params ['restart' ] and not self .is_restartable ():
446460 self ._init_params ['restart' ] = False
0 commit comments