Changeset 6de8198aa4e7b27e09a9a6b83c160510c78c9cd0
- Timestamp:
- 02/04/10 02:03:23
(3 years ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1265249003 +0000
- git-parent:
[9773c9f2c8f4413f348fed53ebb19681bfdfd074]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1265249003 +0000
- Message:
closes #250
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rd857961 |
r6de8198 |
|
| 776 | 776 | outlets = noit_conf_get_sections(log_configs[i], |
|---|
| 777 | 777 | "ancestor-or-self::node()/outlet", &ocnt); |
|---|
| 778 | | noitL(noit_debug, "Found %d outlets for log '%s'\n", ocnt, name); |
|---|
| | 778 | noitL(noit_error, "Found %d outlets for log '%s'\n", ocnt, name); |
|---|
| 779 | 779 | |
|---|
| 780 | 780 | for(o=0; o<ocnt; o++) { |
|---|
| r13c6915 |
r6de8198 |
|
| 260 | 260 | |
|---|
| 261 | 261 | int main(int argc, char **argv) { |
|---|
| | 262 | int fd; |
|---|
| 262 | 263 | char conf_str[1024]; |
|---|
| 263 | 264 | char user[32], group[32]; |
|---|
| … | … | |
| 317 | 318 | if(foreground) return child_main(); |
|---|
| 318 | 319 | |
|---|
| 319 | | close(STDIN_FILENO); |
|---|
| 320 | | close(STDOUT_FILENO); |
|---|
| 321 | | close(STDERR_FILENO); |
|---|
| | 320 | open("/dev/null", O_RDWR); |
|---|
| | 321 | dup2(fd, STDIN_FILENO); |
|---|
| | 322 | dup2(fd, STDOUT_FILENO); |
|---|
| | 323 | dup2(fd, STDERR_FILENO); |
|---|
| 322 | 324 | if(fork()) exit(0); |
|---|
| 323 | 325 | setsid(); |
|---|
| rd94c4d2 |
r6de8198 |
|
| 271 | 271 | |
|---|
| 272 | 272 | int main(int argc, char **argv) { |
|---|
| | 273 | int fd; |
|---|
| 273 | 274 | parse_clargs(argc, argv); |
|---|
| 274 | 275 | |
|---|
| … | … | |
| 282 | 283 | if(foreground) exit(child_main()); |
|---|
| 283 | 284 | |
|---|
| 284 | | close(STDIN_FILENO); |
|---|
| 285 | | close(STDOUT_FILENO); |
|---|
| 286 | | close(STDERR_FILENO); |
|---|
| | 285 | fd = open("/dev/null", O_RDWR); |
|---|
| | 286 | dup2(fd, STDIN_FILENO); |
|---|
| | 287 | dup2(fd, STDOUT_FILENO); |
|---|
| | 288 | dup2(fd, STDERR_FILENO); |
|---|
| 287 | 289 | if(fork()) exit(0); |
|---|
| 288 | 290 | setsid(); |
|---|
| r3fe9ac2 |
r6de8198 |
|
| 58 | 58 | #endif |
|---|
| 59 | 59 | |
|---|
| | 60 | static int DEBUG_LOG_ENABLED() { |
|---|
| | 61 | static int enabled = -1; |
|---|
| | 62 | if(enabled == -1) { |
|---|
| | 63 | char *env = getenv("NOIT_LOG_DEBUG"); |
|---|
| | 64 | enabled = env ? atoi(env) : 0; |
|---|
| | 65 | } |
|---|
| | 66 | return enabled; |
|---|
| | 67 | } |
|---|
| | 68 | #define debug_printf(a...) do { \ |
|---|
| | 69 | if(DEBUG_LOG_ENABLED()) fprintf(stderr, a); \ |
|---|
| | 70 | } while(0) |
|---|
| | 71 | |
|---|
| 60 | 72 | struct _noit_log_stream { |
|---|
| 61 | 73 | unsigned enabled:1; |
|---|
| … | … | |
| 88 | 100 | ls->mode = 0664; |
|---|
| 89 | 101 | fd = open(ls->path, O_CREAT|O_WRONLY|O_APPEND, ls->mode); |
|---|
| | 102 | debug_printf("opened '%s' => %d\n", ls->path, fd); |
|---|
| 90 | 103 | if(fd < 0) { |
|---|
| 91 | 104 | ls->op_ctx = NULL; |
|---|
| … | … | |
| 113 | 126 | int fd; |
|---|
| 114 | 127 | fd = (int)(vpsized_int)ls->op_ctx; |
|---|
| | 128 | debug_printf("writing to %d\n", fd); |
|---|
| 115 | 129 | if(fd < 0) return -1; |
|---|
| 116 | 130 | return write(fd, buf, len); |
|---|
| … | … | |
| 550 | 564 | for(node = ls->outlets; node; node = node->next) { |
|---|
| 551 | 565 | int srv = 0; |
|---|
| | 566 | debug_printf(" %s -> %s\n", ls->name, node->outlet->name); |
|---|
| 552 | 567 | srv = noit_log_line(node->outlet, buffer, len); |
|---|
| 553 | 568 | if(srv) rv = srv; |
|---|