Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #77819 > unrolled thread

Python stdout goes where under systemd? (Was: Example of python service running under systemd?)

Started byTravis Griggs <travisgriggs@gmail.com>
First post2014-09-12 12:05 -0700
Last post2014-09-12 12:05 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Python stdout goes where under systemd? (Was: Example of python service running under systemd?) Travis Griggs <travisgriggs@gmail.com> - 2014-09-12 12:05 -0700

#77819 — Python stdout goes where under systemd? (Was: Example of python service running under systemd?)

FromTravis Griggs <travisgriggs@gmail.com>
Date2014-09-12 12:05 -0700
SubjectPython stdout goes where under systemd? (Was: Example of python service running under systemd?)
Message-ID<mailman.13981.1410548753.18130.python-list@python.org>
Thanks all for the help/advice. I’m getting there.

To experiment/learn, I made a simple python program (/Foo/cyclic.py):
 
    #!/usr/bin/env python3

    import time

    while True:
        time.sleep(5)	
        with open('sound', 'r') as file:
            currentValue = file.read()
        otherValue = 'tick' if currentValue == 'tock' else 'tock'
        with open('sound', 'w') as file:
            file.write(otherValue)
        print(currentValue, '->', otherValue)

Run from the command line, this tick-tocks nicely, both outputting, as well as updating the ‘/Foo/sound’ file on a 5 second period.

I then created a simple .service file:

    [Unit]
    Description=Foo for learning service
    After=network-online.target
    
    [Service]
    Type=simple
    ExecStart=/Foo/cyclic.py
    WorkingDirectory=/Foo
    StandardOutput=journal
    
    [Install]
    WantedBy=multi-user.target

I chose to be “explicit” with some of the default options (Type and StandardOutput).
I finally executed:

    systemctl --system daemon-reload
    systemctl enable foo
    systemctl start foo

It seems to work. Almost. The file is being updated regularly (watch cat /Foo/sound shows the change happening). But I can’t seem to find the output from my print() statement. journalctl -f doesn’t show anything. Nor does tail -f /var/log/syslog or any of the others. It just seems to be going nowhere? Is there something I need to do special to get the print() output going somewhere logable?

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web