@@ -526,12 +526,15 @@ class TaskSchedules {
526
526
*
527
527
* @author Jelle De Loecker <jelle@elevenways.be>
528
528
* @since 1.3.17
529
- * @version 1.3.17
529
+ * @version 1.3.20
530
530
*/
531
- #startFromMenu( task_record ) {
531
+ async #startFromMenu( task_record ) {
532
532
console . log ( 'Manually starting' , task_record . type , 'task:' , task_record ) ;
533
533
let schedule = new TaskSchedule ( this , null , task_record . settings , task_record ) ;
534
- schedule . startManually ( ) ;
534
+ let task_instance = await schedule . startManually ( ) ;
535
+ console . log ( ' -- Started:' , task_instance ) ;
536
+
537
+ return task_instance ;
535
538
}
536
539
537
540
/**
@@ -579,6 +582,7 @@ class TaskSchedule {
579
582
janeway_menu_item = null ;
580
583
581
584
#change_counter = 0 ;
585
+ #instance_pledge = null ;
582
586
583
587
/**
584
588
* Initialize the instance
@@ -845,18 +849,30 @@ class TaskSchedule {
845
849
*
846
850
* @author Jelle De Loecker <jelle@elevenways.be>
847
851
* @since 1.3.17
848
- * @version 1.3.17
852
+ * @version 1.3.20
853
+ *
854
+ * @return {Task }
849
855
*/
850
856
async startManually ( ) {
851
- return this . #run( true ) ;
857
+
858
+ if ( this . is_running ) {
859
+ return false ;
860
+ }
861
+
862
+ let pledge = new Pledge ( ) ;
863
+ this . #instance_pledge = pledge ;
864
+
865
+ this . #run( true ) ;
866
+
867
+ return pledge ;
852
868
}
853
869
854
870
/**
855
871
* Actually run the task
856
872
*
857
873
* @author Jelle De Loecker <jelle@elevenways.be>
858
874
* @since 1.3.17
859
- * @version 1.3.17
875
+ * @version 1.3.20
860
876
*/
861
877
async #run( started_manually = false ) {
862
878
@@ -889,6 +905,12 @@ class TaskSchedule {
889
905
if ( started_manually || await this . ownsScheduledTask ( ) ) {
890
906
let instance = this . createInstance ( ) ;
891
907
this . task_instance = instance ;
908
+
909
+ if ( this . #instance_pledge) {
910
+ this . #instance_pledge. resolve ( instance ) ;
911
+ this . #instance_pledge = null ;
912
+ }
913
+
892
914
await instance . start ( ) ;
893
915
}
894
916
} catch ( err ) {
0 commit comments