httpd: Move starting the http server into C.
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 24m27s
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 24m27s
This commit is contained in:
27
src/task.c
27
src/task.c
@ -376,7 +376,6 @@ static const char* _task_loadFile(tf_task_t* task, const char* fileName, size_t*
|
||||
snprintf(buffer, size, "%s/%s", task->_root_path, fileName);
|
||||
actual = fileName;
|
||||
}
|
||||
tf_printf("opening %s\n", actual);
|
||||
FILE* file = fopen(actual, "rb");
|
||||
if (file)
|
||||
{
|
||||
@ -1727,7 +1726,6 @@ void tf_task_activate(tf_task_t* task)
|
||||
JS_SetPropertyStr(context, global, "TlsContext", tf_tls_context_register(context));
|
||||
tf_file_register(context);
|
||||
tf_database_register(context);
|
||||
tf_httpd_register(context);
|
||||
|
||||
task->_ssb = tf_ssb_create(&task->_loop, task->_context, task->_db_path, task->_network_key);
|
||||
tf_ssb_set_trace(task->_ssb, task->_trace);
|
||||
@ -1744,10 +1742,18 @@ void tf_task_activate(tf_task_t* task)
|
||||
}
|
||||
|
||||
JS_SetPropertyStr(context, tildefriends, "ssb_port", JS_NewInt32(context, actual_ssb_port));
|
||||
JS_SetPropertyStr(context, tildefriends, "http_port", JS_NewInt32(context, task->_http_port));
|
||||
JS_SetPropertyStr(context, tildefriends, "https_port", JS_NewInt32(context, task->_https_port));
|
||||
if (task->_http_port)
|
||||
{
|
||||
JS_SetPropertyStr(context, tildefriends, "http_port", JS_NewInt32(context, task->_http_port));
|
||||
}
|
||||
if (task->_https_port)
|
||||
{
|
||||
JS_SetPropertyStr(context, tildefriends, "https_port", JS_NewInt32(context, task->_https_port));
|
||||
}
|
||||
|
||||
JS_SetPropertyStr(context, global, "getStats", JS_NewCFunction(context, _tf_task_getStats, "getStats", 0));
|
||||
|
||||
tf_httpd_register(context);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2043,6 +2049,19 @@ const char* tf_task_get_root_path(tf_task_t* task)
|
||||
return *task->_root_path ? task->_root_path : NULL;
|
||||
}
|
||||
|
||||
const char* tf_task_get_path_with_root(tf_task_t* task, const char* path)
|
||||
{
|
||||
if (!*task->_root_path)
|
||||
{
|
||||
return tf_strdup(path);
|
||||
}
|
||||
|
||||
size_t size = strlen(task->_root_path) + 1 + strlen(path) + 1;
|
||||
char* result = tf_malloc(size);
|
||||
snprintf(result, size, "%s/%s", task->_root_path, path);
|
||||
return result;
|
||||
}
|
||||
|
||||
void tf_task_set_args(tf_task_t* task, const char* args)
|
||||
{
|
||||
task->_args = args;
|
||||
|
Reference in New Issue
Block a user