aboutsummaryrefslogtreecommitdiffstats
path: root/src/blogc-make/exec.c
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2016-12-27 21:52:25 +0100
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2016-12-27 21:52:25 +0100
commit6974c7030339b0e07086d8a34548396313725346 (patch)
treed7142decb8f5557703bf3026deceef19a96b32e4 /src/blogc-make/exec.c
parent4755ad22cdfa2c7414cc66e068b884f90f2cc639 (diff)
downloadblogc-6974c7030339b0e07086d8a34548396313725346.tar.gz
blogc-6974c7030339b0e07086d8a34548396313725346.tar.bz2
blogc-6974c7030339b0e07086d8a34548396313725346.zip
make: implemented runserver rule
Diffstat (limited to 'src/blogc-make/exec.c')
-rw-r--r--src/blogc-make/exec.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/blogc-make/exec.c b/src/blogc-make/exec.c
index 8b961e7..28dc73d 100644
--- a/src/blogc-make/exec.c
+++ b/src/blogc-make/exec.c
@@ -302,3 +302,34 @@ bm_exec_blogc(bm_settings_t *settings, bc_trie_t *variables, bool listing,
return rv;
}
+
+
+int
+bm_exec_blogc_runserver(bm_settings_t *settings, bool verbose)
+{
+ // use blogc binary from environment, if provided
+ const char *blogc_runserver = getenv("BLOGC_RUNSERVER");
+
+ char *cmd = bc_strdup_printf("%s -t %s -p %s -m %s %s",
+ blogc_runserver != NULL ? blogc_runserver : "blogc-runserver",
+ bc_trie_lookup(settings->settings, "runserver_host"),
+ bc_trie_lookup(settings->settings, "runserver_port"),
+ bc_trie_lookup(settings->settings, "runserver_threads"),
+ bc_trie_lookup(settings->settings, "output_dir"));
+
+ if (verbose)
+ printf("%s\n", cmd);
+ else
+ printf("\n");
+ fflush(stdout);
+
+ // we don't need pipes to run blogc-runserver, because it is "interactive"
+ int rv = system(cmd);
+ free(cmd);
+
+ if (rv != 0)
+ fprintf(stderr,
+ "error: Failed to execute command, returned status code: %d\n", rv);
+
+ return rv;
+}