diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2018-05-14 19:15:12 +0200 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2018-05-14 18:05:13 +0200 |
commit | 8481ecfd2b2f820bcd4c82d300c1f5fda48eb9ed (patch) | |
tree | dd069f60fef74ee1f41526326c0c8f90df0a78b5 /src/blogc-make/httpd.c | |
parent | ecd5034aca6029c1900f8d681fafb2f5177a7f0b (diff) | |
download | blogc-8481ecfd2b2f820bcd4c82d300c1f5fda48eb9ed.tar.gz blogc-8481ecfd2b2f820bcd4c82d300c1f5fda48eb9ed.tar.bz2 blogc-8481ecfd2b2f820bcd4c82d300c1f5fda48eb9ed.zip |
make: run the build rule before starting httpd for runserver rule
Diffstat (limited to 'src/blogc-make/httpd.c')
-rw-r--r-- | src/blogc-make/httpd.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/blogc-make/httpd.c b/src/blogc-make/httpd.c index 7d67b57..a302eb4 100644 --- a/src/blogc-make/httpd.c +++ b/src/blogc-make/httpd.c @@ -10,6 +10,7 @@ #include <stdlib.h> #include <string.h> #include <pthread.h> +#include <unistd.h> #include "../common/utils.h" #include "ctx.h" #include "exec.h" @@ -47,6 +48,17 @@ int bm_httpd_run(bm_ctx_t **ctx, bm_rule_exec_func_t rule_exec, bc_slist_t *outputs, bc_trie_t *args) { + // this is here to avoid that the httpd starts running in the middle of the + // first build, as the reloader and the httpd are started in parallel. + // we run the task synchronously for the first time, and start the httpd + // thread afterwards. + bool wait_before_reloader = false; + if (0 != rule_exec(*ctx, outputs, args)) { + fprintf(stderr, "blogc-make: warning: failed to rebuild website. " + "retrying in 5 seconds ...\n\n"); + wait_before_reloader = true; + } + int err; pthread_attr_t attr; @@ -77,5 +89,8 @@ bm_httpd_run(bm_ctx_t **ctx, bm_rule_exec_func_t rule_exec, bc_slist_t *outputs, } // run the reloader + if (wait_before_reloader) { + sleep(5); + } return bm_reloader_run(ctx, rule_exec, outputs, args); } |