Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Initscript stdout Gets Lost [solved]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
duane
Apprentice
Apprentice


Joined: 03 Jun 2002
Posts: 193
Location: Oklahoma City

PostPosted: Sun May 19, 2019 6:57 am    Post subject: Initscript stdout Gets Lost [solved] Reply with quote

I made a simple initscript for a python program that I want to run as a service, and it seems to work fine except that the python print statements don't make it into my log.

Code:
#!/sbin/openrc-run
# Copyright 2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

name="homepage daemon"
description="Duane's homepage daemon"
command=/usr/bin/python3
command_args="/home/duane/bin/python/homepage.py"
command_background=true
command_user=duane:duane
pidfile=/run/duane/homepage.pid
output_log=/var/log/duane/homepage.log
error_log=/var/log/duane/homepage-errors.log
start_stop_daemon_args="--env \"TRASH_PATH=/home/duane/.local/share/Trash\""

depend() {
    need net
}


The script starts and stops, its pidfile is correct, and zero-length log files are created (owned by duane), but they never fill.

I've been reading the handbook entry on working with initscripts, but haven't spotted the problem. Can anyone point me in the right direction?


Last edited by duane on Sun May 19, 2019 4:31 pm; edited 1 time in total
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 21724

PostPosted: Sun May 19, 2019 4:03 pm    Post subject: Reply with quote

Use lsof to list the open descriptors of the daemon. Check what file(s) descriptors 1 and 2 use.

Are you using a version of OpenRC that understands output_log and error_log? You can assign any variables you want, but if OpenRC doesn't understand them, they will be ignored.
Back to top
View user's profile Send private message
duane
Apprentice
Apprentice


Joined: 03 Jun 2002
Posts: 193
Location: Oklahoma City

PostPosted: Sun May 19, 2019 4:30 pm    Post subject: Reply with quote

After eight hours or so, I have some information in the error log from wget invocations, so I guess it's just buffering more than I expected. It's not a major issue in this case. I think I'll write future scripts to print to the log directly though.

Thanks for the help.
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 21724

PostPosted: Sun May 19, 2019 5:53 pm    Post subject: Reply with quote

You could also choose to proactively flush output in your script. When stdout is a terminal, it is usually line-buffered by default. When it is a file, it is usually block-buffered. You can override these defaults to force line buffered logs, or you could explicitly flush stdout after writing all the lines that are relevant to this wakeup.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum