From: Rebelo on
i get : IOError: [Errno 9] Bad file descriptor
when i have logging and using daemon.DaemonContext()
i tried passing :
fh = logging.handlers.TimedRotatingFileHandler(LOG_FILENAME, 'midnight',
encoding='utf-8')
with :
context = daemon.DaemonContext()
context.files_preserve=[fh]

but no good
what am i doing wrong?
From: Rebelo on
when i use this :
context = daemon.DaemonContext(stdin=sys.stdin, stdout=sys.stdout,
files_preserve=[fh], signal_map = {signal.SIGTERM:
'terminate',signal.SIGHUP: 'terminate'})

i don't get error but i still can't write to log file
what am i doing wrong?
From: Vinay Sajip on
On Apr 8, 1:28 pm, Rebelo <puntabl...(a)gmail.com> wrote:
> when i use this :
>  context = daemon.DaemonContext(stdin=sys.stdin, stdout=sys.stdout,
> files_preserve=[fh], signal_map = {signal.SIGTERM:
> 'terminate',signal.SIGHUP: 'terminate'})
>
> i don't get error but i still can't write to log file
> what am i doing wrong?

Not sure, offhand.

Change to a script which just writes to the file (rather than going
via logging) - does that work? What platform are you on, what version
etc?

It's unlikely to be a logging-related problem: more likely it's to do
with file descriptors.

Regards,

Vinay Sajip
From: Vinay Sajip on
On Apr 8, 1:28 pm, Rebelo <puntabl...(a)gmail.com> wrote:
> when i use this :
>  context = daemon.DaemonContext(stdin=sys.stdin, stdout=sys.stdout,
> files_preserve=[fh], signal_map = {signal.SIGTERM:
> 'terminate',signal.SIGHUP: 'terminate'})
>
> i don't get error but i still can't write to log file
> what am i doing wrong?

My guess is - files_preserve needs to be passed a file handle and not
a logging handler.

Regards,

Vinay Sajip
From: Rebelo on
Vinay Sajip wrote:
> On Apr 8, 1:28 pm, Rebelo <puntabl...(a)gmail.com> wrote:
>> when i use this :
>> context = daemon.DaemonContext(stdin=sys.stdin, stdout=sys.stdout,
>> files_preserve=[fh], signal_map = {signal.SIGTERM:
>> 'terminate',signal.SIGHUP: 'terminate'})
>>
>> i don't get error but i still can't write to log file
>> what am i doing wrong?
>
> My guess is - files_preserve needs to be passed a file handle and not
> a logging handler.
>
> Regards,
>
> Vinay Sajip

thnx for help.
writing to a file works, but i need logging.
do you know where can i find good documnetation for python-daemon?