Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fanout
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gerhard Gonter
fanout
Commits
521fb89e
Commit
521fb89e
authored
May 22, 2012
by
Travis Glenn Hansen
Browse files
Options
Downloads
Patches
Plain Diff
adding --max-logfile-size param
parent
3bd2ceb1
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
fanout.c
+46
-22
46 additions, 22 deletions
fanout.c
with
46 additions
and
22 deletions
fanout.c
+
46
−
22
View file @
521fb89e
...
@@ -120,6 +120,7 @@ unsigned long long client_limit_count = 0;
...
@@ -120,6 +120,7 @@ unsigned long long client_limit_count = 0;
static
int
daemonize
=
0
;
static
int
daemonize
=
0
;
FILE
*
logfile
;
FILE
*
logfile
;
long
max_logfile_size
=
-
1
;
// 0 = ERROR
// 0 = ERROR
// 1 = WARNING
// 1 = WARNING
...
@@ -169,6 +170,7 @@ int main (int argc, char *argv[])
...
@@ -169,6 +170,7 @@ int main (int argc, char *argv[])
{
"help"
,
0
,
0
,
0
},
{
"help"
,
0
,
0
,
0
},
{
"client-limit"
,
1
,
0
,
0
},
{
"client-limit"
,
1
,
0
,
0
},
{
"run-as"
,
1
,
0
,
0
},
{
"run-as"
,
1
,
0
,
0
},
{
"max-logfile-size"
,
1
,
0
,
0
},
{
NULL
,
0
,
NULL
,
0
}
{
NULL
,
0
,
NULL
,
0
}
};
};
...
@@ -204,11 +206,11 @@ int main (int argc, char *argv[])
...
@@ -204,11 +206,11 @@ int main (int argc, char *argv[])
printf
(
"Usage: fanout [options...]
\n
"
);
printf
(
"Usage: fanout [options...]
\n
"
);
printf
(
"pubsub style fanout server
\n\n
"
);
printf
(
"pubsub style fanout server
\n\n
"
);
printf
(
"Recognized options are:
\n
"
);
printf
(
"Recognized options are:
\n
"
);
printf
(
" --port=PORT port to run the serv
ice
\
printf
(
" --port=PORT
port to run the serv\
on
\n
"
);
ice
on
\n
"
);
printf
(
" 1986 (default)
\n
"
);
printf
(
" 1986 (default)
\n
"
);
printf
(
" --run-as=USER[:GROUP] drop permissions to
def
\
printf
(
" --run-as=USER[:GROUP]
drop permissions to \
ined levels
\n
"
);
def
ined levels
\n
"
);
printf
(
" --daemon fork to background
\n
"
);
printf
(
" --daemon fork to background
\n
"
);
printf
(
" --client-limit=LIMIT max connections
\n
"
);
printf
(
" --client-limit=LIMIT max connections
\n
"
);
printf
(
" BEWARE ulimit \
printf
(
" BEWARE ulimit \
...
@@ -219,9 +221,11 @@ restrictions\n");
...
@@ -219,9 +221,11 @@ restrictions\n");
fs.file-max=100000
\n
"
);
fs.file-max=100000
\n
"
);
printf
(
" --logfile=PATH path to log file
\n
"
);
printf
(
" --logfile=PATH path to log file
\n
"
);
printf
(
" --max-logfile-size=SIZE logfile size in MB
\n
"
);
printf
(
" --pidfile=PATH path to pid file
\n
"
);
printf
(
" --pidfile=PATH path to pid file
\n
"
);
printf
(
" --debug-level=LEVEL verbosity level
\n
"
);
printf
(
" --debug-level=LEVEL verbosity level
\n
"
);
printf
(
" 0 = ERROR (default)
\n
"
);
printf
(
" \
0 = ERROR (default)
\n
"
);
printf
(
" 1 = WARNING
\n
"
);
printf
(
" 1 = WARNING
\n
"
);
printf
(
" 2 = INFO
\n
"
);
printf
(
" 2 = INFO
\n
"
);
printf
(
" 3 = DEBUG
\n
"
);
printf
(
" 3 = DEBUG
\n
"
);
...
@@ -270,6 +274,13 @@ fs.file-max=100000\n");
...
@@ -270,6 +274,13 @@ fs.file-max=100000\n");
break
;
break
;
//max-logfile-size
case
8
:
fanout_debug
(
3
,
"max logfile size: %s MB
\n
"
,
optarg
);
max_logfile_size
=
atol
(
optarg
);
break
;
}
}
break
;
break
;
default:
default:
...
@@ -602,7 +613,7 @@ char *str_append (char *target, const char *data)
...
@@ -602,7 +613,7 @@ char *str_append (char *target, const char *data)
void
fanout_error
(
const
char
*
msg
)
void
fanout_error
(
const
char
*
msg
)
{
{
perror
(
msg
);
fanout_debug
(
0
,
"%s: %s
\n
"
,
msg
,
strerror
(
errno
)
);
exit
(
1
);
exit
(
1
);
}
}
...
@@ -637,11 +648,24 @@ void fanout_debug (int level, const char *format, ...)
...
@@ -637,11 +648,24 @@ void fanout_debug (int level, const char *format, ...)
message
=
str_append
(
message
,
data
);
message
=
str_append
(
message
,
data
);
if
(
debug_level
>=
level
)
{
if
(
debug_level
>=
level
)
{
if
(
daemonize
&&
logfile
!=
NULL
)
{
if
(
!
daemonize
)
printf
(
"%s"
,
message
);
if
(
logfile
!=
NULL
)
{
if
(
max_logfile_size
>
0
)
{
long
current_pos
;
long
filesize
;
if
((
current_pos
=
ftell
(
logfile
))
==
-
1
)
exit
(
EXIT_FAILURE
);
//MB
filesize
=
(
current_pos
/
1024
/
1024
);
if
(
filesize
>=
max_logfile_size
)
{
if
((
ftruncate
(
fileno
(
logfile
),
(
off_t
)
0
))
==
-
1
)
exit
(
EXIT_FAILURE
);
}
}
fprintf
(
logfile
,
"%s"
,
message
);
fprintf
(
logfile
,
"%s"
,
message
);
fflush
(
logfile
);
fflush
(
logfile
);
}
else
{
printf
(
"%s"
,
message
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment