On Sat, Oct 19, 2013 at 11:35:34PM +0900, Hitoshi Mitake wrote:
> From: Hitoshi Mitake <mitake.hito...@lab.ntt.co.jp>
> 
> Current sheep process rotates log when the log file reaches its
> maximum size (500MB). But it is not comfortable for periodical backup
> of log files.
> 
> Rotating log with catching SIGHUP is a common behavior of unix
> processes. This patch implements the behavior in sheep daemon.
> 
> Example of rog lotation:
> $ sudo sheep -P /tmp/sheep/sheep.pid -c local /tmp/sheep
> $ sudo kill -SIGHUP `sudo cat /tmp/sheep/sheep.pid`
> 
> Signed-off-by: Hitoshi Mitake <mitake.hito...@lab.ntt.co.jp>
> ---
>  CHANGELOG.md     |  1 +
>  include/logger.h |  2 ++
>  lib/logger.c     | 56 
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
>  sheep/sheep.c    | 11 +++++++++++
>  4 files changed, 68 insertions(+), 2 deletions(-)
> 
> diff --git a/CHANGELOG.md b/CHANGELOG.md
> index 771d69b..5fde0ee 100644
> --- a/CHANGELOG.md
> +++ b/CHANGELOG.md
> @@ -14,3 +14,4 @@ DOG COMMAND INTERFACE:
>  SHEEP COMMAND INTERFACE:
>   - improvements of help messages
>   - change format of the size format in -j (journaling) and -w (object cache) 
> options. The new format is: n[TtGgMmKkb]. e.g. "-j size=1024M".
> + - rotate log when sheep process catches SIGHUP signal
> diff --git a/include/logger.h b/include/logger.h
> index 3f9292d..a86c369 100644
> --- a/include/logger.h
> +++ b/include/logger.h
> @@ -90,4 +90,6 @@ void sd_backtrace(void);
>  void set_loglevel(int new_loglevel);
>  int get_loglevel(void);
>  
> +extern pid_t logger_pid;
> +
>  #endif       /* LOG_H */
> diff --git a/lib/logger.c b/lib/logger.c
> index bf1a605..4ee3027 100644
> --- a/lib/logger.c
> +++ b/lib/logger.c
> @@ -114,12 +114,39 @@ static const char *log_name;
>  static char *log_nowname;
>  int sd_log_level = SDOG_INFO;
>  static pid_t sheep_pid;
> -static pid_t logger_pid;
> +pid_t logger_pid = -1;
>  static key_t semkey;
>  static char *log_buff;
>  
>  static int64_t max_logsize = 500 * 1024 * 1024;  /*500MB*/
>  
> +static void block_sighup(void)
> +{
> +     /* this function is used for protecting log_fd */

Put the function description above the function name.

Thanks
Yuan
-- 
sheepdog mailing list
sheepdog@lists.wpkg.org
http://lists.wpkg.org/mailman/listinfo/sheepdog

Reply via email to