@@ -80,11 +80,13 @@ int nprocesses=0;
8080int quiet = 0 ;
8181int verbose = 0 ;
8282int force = 0 ;
83+ int non_interactive = 0 ;
8384int sig_int_received = 0 ;
8485int error_detected = 0 ;
8586double percent_failed_allowed = 1.0 ;
8687int n_metatiles_tot = 0 ;
8788int n_nodata_tot = 0 ;
89+ int n_skipped_tot = 0 ;
8890int rate_limit = 0 ;
8991FILE * failed_log = NULL , * retry_log = NULL ;
9092#define FAIL_BACKLOG_COUNT 1000
@@ -127,6 +129,7 @@ struct seed_status {
127129 s_status status ;
128130 int x ,y ,z ;
129131 int nodata ;
132+ int skipped ;
130133 char * msg ;
131134};
132135
@@ -263,6 +266,7 @@ static const apr_getopt_option_t seed_options[] = {
263266#endif
264267 { "tileset" , 't' , TRUE, "tileset to seed" },
265268 { "verbose" , 'v' , FALSE, "show debug log messages" },
269+ { "non-interactive" , 'b' , FALSE, "print progress messages on new lines" },
266270#ifdef USE_CLIPPERS
267271 { "ogr-where" , 'w' , TRUE, "filter to apply on layer features" },
268272#endif
@@ -496,8 +500,23 @@ void cmd_recurse(mapcache_context *cmd_ctx, mapcache_tile *tile)
496500 if (rate_limit > 0 )
497501 rate_limit_sleep ();
498502 push_queue (cmd );
503+ } else if (action == MAPCACHE_CMD_SKIP ) {
504+ apr_status_t ret ;
505+ struct seed_status * st = calloc (1 ,sizeof (struct seed_status ));
506+ int retries = 0 ;
507+ st -> x = tile -> x ;
508+ st -> y = tile -> y ;
509+ st -> z = tile -> z ;
510+ st -> nodata = 0 ;
511+ st -> skipped = 1 ;
512+ st -> status = MAPCACHE_STATUS_OK ;
513+ ret = apr_queue_push (log_queue ,(void * )st );
514+ while ( ret == APR_EINTR && retries < 10 ) {
515+ retries ++ ;
516+ ret = apr_queue_push (log_queue ,(void * )st );
517+ }
499518 }
500-
519+
501520 if (action == MAPCACHE_CMD_STOP_RECURSION )
502521 return ;
503522
@@ -619,6 +638,21 @@ void feed_worker()
619638 if (rate_limit > 0 )
620639 rate_limit_sleep ();
621640 push_queue (cmd );
641+ } else if (action == MAPCACHE_CMD_SKIP ) {
642+ apr_status_t ret ;
643+ struct seed_status * st = calloc (1 ,sizeof (struct seed_status ));
644+ int retries = 0 ;
645+ st -> x = tile -> x ;
646+ st -> y = tile -> y ;
647+ st -> z = tile -> z ;
648+ st -> nodata = 0 ;
649+ st -> skipped = 1 ;
650+ st -> status = MAPCACHE_STATUS_OK ;
651+ ret = apr_queue_push (log_queue ,(void * )st );
652+ while ( ret == APR_EINTR && retries < 10 ) {
653+ retries ++ ;
654+ ret = apr_queue_push (log_queue ,(void * )st );
655+ }
622656 }
623657
624658 //compute next x,y,z
@@ -725,6 +759,7 @@ void seed_worker()
725759 st -> y = tile -> y ;
726760 st -> z = tile -> z ;
727761 st -> nodata = tile -> nodata ;
762+ st -> skipped = 0 ;
728763 if (seed_ctx .get_error (& seed_ctx )) {
729764 st -> status = MAPCACHE_STATUS_FAIL ;
730765 st -> msg = strdup (seed_ctx .get_error_message (& seed_ctx ));
@@ -793,7 +828,11 @@ static void* APR_THREAD_FUNC log_thread_fn(apr_thread_t *thread, void *data) {
793828 return NULL ;
794829 if (st -> status == MAPCACHE_STATUS_OK ) {
795830 failed [cur ]= 0 ;
796- n_metatiles_tot ++ ;
831+ if (st -> skipped ) {
832+ n_skipped_tot ++ ;
833+ } else {
834+ n_metatiles_tot ++ ;
835+ }
797836 if (st -> nodata ) {
798837 n_nodata_tot ++ ;
799838 }
@@ -802,9 +841,16 @@ static void* APR_THREAD_FUNC log_thread_fn(apr_thread_t *thread, void *data) {
802841 mapcache_gettimeofday (& now ,NULL );
803842 now_time = now .tv_sec + now .tv_usec / 1000000.0 ;
804843 if ((now_time - last_time ) > 1.0 ) {
805- printf (" \r" );
806- printf ("seeded %d tiles, now at z%d x%d y%d\r" ,n_metatiles_tot * tileset -> metasize_x * tileset -> metasize_y , st -> z ,st -> x ,st -> y );
807- fflush (stdout );
844+ int seeded_count = n_metatiles_tot * tileset -> metasize_x * tileset -> metasize_y ;
845+ int skipped_count = n_skipped_tot * tileset -> metasize_x * tileset -> metasize_y ;
846+ if (non_interactive ) {
847+ printf ("seeded %d tiles (%d skipped), now at z%d x%d y%d\n" ,seeded_count ,skipped_count ,st -> z ,st -> x ,st -> y );
848+ } else {
849+ printf (" \r" );
850+ printf ("seeded %d tiles (%d skipped), now at z%d x%d y%d\r" ,seeded_count ,skipped_count ,st -> z ,st -> x ,st -> y );
851+ fflush (stdout );
852+ }
853+
808854 last_time = now_time ;
809855 }
810856 }
@@ -964,6 +1010,9 @@ int main(int argc, const char **argv)
9641010 case 'v' :
9651011 verbose = 1 ;
9661012 break ;
1013+ case 'b' :
1014+ non_interactive = 1 ;
1015+ break ;
9671016 case 'c' :
9681017 configfile = optarg ;
9691018 break ;
@@ -1409,7 +1458,7 @@ int main(int argc, const char **argv)
14091458 if (nthreads >= 1 && nprocesses >= 1 ) {
14101459 return usage (argv [0 ],"cannot set both nthreads and nprocesses" );
14111460 }
1412-
1461+
14131462 {
14141463 /* start the logging thread */
14151464 //create the queue where the seeding statuses will be put
@@ -1420,7 +1469,7 @@ int main(int argc, const char **argv)
14201469 apr_threadattr_create (& log_thread_attrs , ctx .pool );
14211470 apr_thread_create (& log_thread , log_thread_attrs , log_thread_fn , NULL , ctx .pool );
14221471 }
1423-
1472+
14241473 if (nprocesses > 1 ) {
14251474#ifdef USE_FORK
14261475 key_t key ;
0 commit comments