summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_application.c
diff options
context:
space:
mode:
authorKonstantin Pavlov <thresh@nginx.com>2023-05-10 10:29:16 -0700
committerKonstantin Pavlov <thresh@nginx.com>2023-05-10 10:29:16 -0700
commit69235c513277c64b513447d9b92c3c03d616f577 (patch)
tree0780c92ba28d92b547c85ea0bee5e3040e14dee2 /src/nxt_application.c
parentb9bc222021e77bbdfb12576b3e315b962cf6b399 (diff)
parentfaf97dc06058de1c929af33a68adb34d3932b374 (diff)
downloadunit-1.30.0-1.tar.gz
unit-1.30.0-1.tar.bz2
Merged with the default branch.1.30.0-1
Diffstat (limited to '')
-rw-r--r--src/nxt_application.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/nxt_application.c b/src/nxt_application.c
index 786c768b..ffa8eb53 100644
--- a/src/nxt_application.c
+++ b/src/nxt_application.c
@@ -933,6 +933,59 @@ nxt_app_set_environment(nxt_conf_value_t *environment)
}
+nxt_int_t
+nxt_app_set_logs(void)
+{
+ nxt_int_t ret;
+ nxt_file_t file;
+ nxt_task_t *task;
+ nxt_thread_t *thr;
+ nxt_process_t *process;
+ nxt_runtime_t *rt;
+ nxt_common_app_conf_t *app_conf;
+
+ thr = nxt_thread();
+
+ task = thr->task;
+
+ rt = task->thread->runtime;
+ if (!rt->daemon) {
+ return NXT_OK;
+ }
+
+ process = rt->port_by_type[NXT_PROCESS_PROTOTYPE]->process;
+ app_conf = process->data.app;
+
+ if (app_conf->stdout_log != NULL) {
+ nxt_memzero(&file, sizeof(nxt_file_t));
+ file.log_level = 1;
+ file.name = (u_char *) app_conf->stdout_log;
+ ret = nxt_file_open(task, &file, O_WRONLY | O_APPEND, O_CREAT, 0666);
+ if (ret == NXT_ERROR) {
+ return NXT_ERROR;
+ }
+
+ nxt_file_stdout(&file);
+ nxt_file_close(task, &file);
+ }
+
+ if (app_conf->stderr_log != NULL) {
+ nxt_memzero(&file, sizeof(nxt_file_t));
+ file.log_level = 1;
+ file.name = (u_char *) app_conf->stderr_log;
+ ret = nxt_file_open(task, &file, O_WRONLY | O_APPEND, O_CREAT, 0666);
+ if (ret == NXT_ERROR) {
+ return NXT_ERROR;
+ }
+
+ nxt_file_stderr(&file);
+ nxt_file_close(task, &file);
+ }
+
+ return NXT_OK;
+}
+
+
static u_char *
nxt_cstr_dup(nxt_mp_t *mp, u_char *dst, u_char *src)
{