nxt_runtime.c (230:e00ffd51df10) nxt_runtime.c (231:6832cdee961e)
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) Valentin V. Bartenev
5 * Copyright (C) NGINX, Inc.
6 */
7
8#include <nxt_main.h>

--- 64 unchanged lines hidden (view full) ---

73 return NXT_ERROR;
74 }
75
76 task->thread->runtime = rt;
77 rt->mem_pool = mp;
78
79 nxt_thread_mutex_create(&rt->processes_mutex);
80
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) Valentin V. Bartenev
5 * Copyright (C) NGINX, Inc.
6 */
7
8#include <nxt_main.h>

--- 64 unchanged lines hidden (view full) ---

73 return NXT_ERROR;
74 }
75
76 task->thread->runtime = rt;
77 rt->mem_pool = mp;
78
79 nxt_thread_mutex_create(&rt->processes_mutex);
80
81 rt->prefix = nxt_current_directory(mp);
82 if (nxt_slow_path(rt->prefix == NULL)) {
83 goto fail;
84 }
85
86 rt->conf_prefix = rt->prefix;
87
88 rt->services = nxt_services_init(mp);
89 if (nxt_slow_path(rt->services == NULL)) {
90 goto fail;
91 }
92
93 rt->languages = nxt_array_create(mp, 1, sizeof(nxt_app_lang_module_t));
94 if (nxt_slow_path(rt->languages == NULL)) {
95 goto fail;

--- 597 unchanged lines hidden (view full) ---

693 }
694}
695
696
697static nxt_int_t
698nxt_runtime_conf_init(nxt_task_t *task, nxt_runtime_t *rt)
699{
700 nxt_int_t ret;
81 rt->services = nxt_services_init(mp);
82 if (nxt_slow_path(rt->services == NULL)) {
83 goto fail;
84 }
85
86 rt->languages = nxt_array_create(mp, 1, sizeof(nxt_app_lang_module_t));
87 if (nxt_slow_path(rt->languages == NULL)) {
88 goto fail;

--- 597 unchanged lines hidden (view full) ---

686 }
687}
688
689
690static nxt_int_t
691nxt_runtime_conf_init(nxt_task_t *task, nxt_runtime_t *rt)
692{
693 nxt_int_t ret;
701 nxt_str_t *prefix;
702 nxt_file_t *file;
703 nxt_file_name_str_t file_name;
704 const nxt_event_interface_t *interface;
705
706 rt->daemon = 1;
707 rt->master_process = 1;
708 rt->engine_connections = 256;
709 rt->auxiliary_threads = 2;
710 rt->user_cred.user = "nobody";
711 rt->group = NULL;
694 nxt_file_t *file;
695 nxt_file_name_str_t file_name;
696 const nxt_event_interface_t *interface;
697
698 rt->daemon = 1;
699 rt->master_process = 1;
700 rt->engine_connections = 256;
701 rt->auxiliary_threads = 2;
702 rt->user_cred.user = "nobody";
703 rt->group = NULL;
712 rt->pid = "nginext.pid";
704 rt->pid = NXT_PID;
713 rt->log = NXT_LOG;
714
715 if (nxt_runtime_conf_read_cmd(task, rt) != NXT_OK) {
716 return NXT_ERROR;
717 }
718
719 if (nxt_runtime_controller_socket(task, rt) != NXT_OK) {
720 return NXT_ERROR;

--- 7 unchanged lines hidden (view full) ---

728
729 interface = nxt_service_get(rt->services, "engine", rt->engine);
730 if (interface == NULL) {
731 return NXT_ERROR;
732 }
733
734 rt->engine = interface->name;
735
705 rt->log = NXT_LOG;
706
707 if (nxt_runtime_conf_read_cmd(task, rt) != NXT_OK) {
708 return NXT_ERROR;
709 }
710
711 if (nxt_runtime_controller_socket(task, rt) != NXT_OK) {
712 return NXT_ERROR;

--- 7 unchanged lines hidden (view full) ---

720
721 interface = nxt_service_get(rt->services, "engine", rt->engine);
722 if (interface == NULL) {
723 return NXT_ERROR;
724 }
725
726 rt->engine = interface->name;
727
736 prefix = nxt_file_name_is_absolute(rt->pid) ? NULL : rt->prefix;
737
738 ret = nxt_file_name_create(rt->mem_pool, &file_name, "%V%s%Z",
739 prefix, rt->pid);
728 ret = nxt_file_name_create(rt->mem_pool, &file_name, "s%Z", rt->pid);
740 if (nxt_slow_path(ret != NXT_OK)) {
741 return NXT_ERROR;
742 }
743
744 rt->pid_file = file_name.start;
745
746 ret = nxt_file_name_create(rt->mem_pool, &file_name, "%s%Z", rt->log);
747 if (nxt_slow_path(ret != NXT_OK)) {

--- 15 unchanged lines hidden (view full) ---

763 nxt_str_t addr;
764 nxt_sockaddr_t *sa;
765 u_char buf[1024];
766
767 static const char version[] =
768 "nginext version: " NXT_VERSION "\n"
769 "configured as ./configure" NXT_CONFIGURE_OPTIONS "\n";
770
729 if (nxt_slow_path(ret != NXT_OK)) {
730 return NXT_ERROR;
731 }
732
733 rt->pid_file = file_name.start;
734
735 ret = nxt_file_name_create(rt->mem_pool, &file_name, "%s%Z", rt->log);
736 if (nxt_slow_path(ret != NXT_OK)) {

--- 15 unchanged lines hidden (view full) ---

752 nxt_str_t addr;
753 nxt_sockaddr_t *sa;
754 u_char buf[1024];
755
756 static const char version[] =
757 "nginext version: " NXT_VERSION "\n"
758 "configured as ./configure" NXT_CONFIGURE_OPTIONS "\n";
759
760 static const char no_pid[] = "option \"--pid\" requires filename\n";
771 static const char no_log[] = "option \"--log\" requires filename\n";
772
773 argv = &nxt_process_argv[1];
774
775 while (*argv != NULL) {
776 p = *argv++;
777
778 if (nxt_strcmp(p, "--listen") == 0) {

--- 59 unchanged lines hidden (view full) ---

838
839 rt->group = p;
840
841 continue;
842 }
843
844 if (nxt_strcmp(p, "--pid") == 0) {
845 if (*argv == NULL) {
761 static const char no_log[] = "option \"--log\" requires filename\n";
762
763 argv = &nxt_process_argv[1];
764
765 while (*argv != NULL) {
766 p = *argv++;
767
768 if (nxt_strcmp(p, "--listen") == 0) {

--- 59 unchanged lines hidden (view full) ---

828
829 rt->group = p;
830
831 continue;
832 }
833
834 if (nxt_strcmp(p, "--pid") == 0) {
835 if (*argv == NULL) {
846 nxt_log(task, NXT_LOG_CRIT,
847 "no argument for option \"--pid\"");
836 write(STDERR_FILENO, no_pid, sizeof(no_pid) - 1);
848 return NXT_ERROR;
849 }
850
851 p = *argv++;
852
853 rt->pid = p;
854
855 continue;

--- 891 unchanged lines hidden ---
837 return NXT_ERROR;
838 }
839
840 p = *argv++;
841
842 rt->pid = p;
843
844 continue;

--- 891 unchanged lines hidden ---