View previous topic :: View next topic |
Author |
Message |
duane Apprentice
Joined: 03 Jun 2002 Posts: 193 Location: Oklahoma City
|
Posted: Sun May 19, 2019 6:57 am Post subject: Initscript stdout Gets Lost [solved] |
|
|
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 |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 21724
|
Posted: Sun May 19, 2019 4:03 pm Post subject: |
|
|
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 |
|
|
duane Apprentice
Joined: 03 Jun 2002 Posts: 193 Location: Oklahoma City
|
Posted: Sun May 19, 2019 4:30 pm Post subject: |
|
|
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 |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 21724
|
Posted: Sun May 19, 2019 5:53 pm Post subject: |
|
|
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 |
|
|
|