Made a new systemd service, where is my output going?

I’m running debian on my BBB (2014-05-14), and I noticed that you guys are using systemd so when I made my new server app I’m using systemd. Here’s my server file, pretty simple:

[Unit]
Description=CS XMLRPC Server
Requires=network.target
After=network.target

[Service]
ExecStart=/usr/local/bin/cs_xmlrpc 8888

[Install]
WantedBy=multi-user.target

I can start/stop it fine, however I can’t seem to find where the stdout/stderr from the program is going. I’ve checked /var/log/syslog, /var/log/messages, dmesg, and systemd-journalctl. None of them seem to contain the output from my program. I’ve read everywhere that it’s either syslog or journalctl, so I don’t know where else to look.

Any ideas? Should I use one of the debian testing snapshots instead?

Thanks,
-Devin

Maybe you can use "status". It's not all the output, but it can help.

systemctl status your_service

For more information:
https://fedoraproject.org/wiki/Systemd

Miguel Zacatei Aveiro
Brascontrol Ind. Com. LTDA
Alameda Araguaia 560 - Alphaville
CEP 06400-000 - Barueri - SP
TEL.: 55 11 4166 1981

Maybe you can use "status". It's not all the output, but it can help.

systemctl status your_service

For more information:
https://fedoraproject.org/wiki/Systemd

Miguel Aveiro

Yeah, I’ve seen that elsewhere before but it still doesn’t work:

root@anna-bone:~/cs_xmlrpc/deb$ systemctl start cs_xmlrpc.service
root@anna-bone:~/cs_xmlrpc/deb$ systemctl status cs_xmlrpc.service
cs_xmlrpc.service - CS XMLRPC Server
          Loaded: loaded (/lib/systemd/system/cs_xmlrpc.service; enabled)
          Active: active (running) since Tue, 13 Jan 2015 15:52:36 +0000; 8s ago
        Main PID: 3565 (cs_xmlrpc)
          CGroup: name=systemd:/system/cs_xmlrpc.service
                  └ 3565 /usr/local/bin/cs_xmlrpc 8888

root@anna-bone:~/cs_xmlrpc/deb$ systemctl stop cs_xmlrpc.service
root@anna-bone:~/cs_xmlrpc/deb$ systemctl status cs_xmlrpc.service
cs_xmlrpc.service - CS XMLRPC Server
          Loaded: loaded (/lib/systemd/system/cs_xmlrpc.service; enabled)
          Active: inactive (dead) since Tue, 13 Jan 2015 15:54:10 +0000; 1s ago
         Process: 3565 ExecStart=/usr/local/bin/cs_xmlrpc 8888 (code=killed, signal=TERM)
          CGroup: name=systemd:/system/cs_xmlrpc.service

If I run the daemon manually you can see what it should output:

root@anna-bone:~/cs_xmlrpc/deb$ ../cs_xmlrpc 
Using config file /etc/cs_xmlrpc.d/cs_xmlrpc.conf
Opened /dev/i2c-1 with i2c address 0x40
Global ID: 0x03e5
Running XML-RPC server at http://anna-bone:8888

This is just to stdout, I’m not doing anything fancy here (just printfs)…

Do you think I just have to update to one of the newer debian snapshots?

-Devin

Sorry, but unfortunately I don't know systemd that well.

I have an old snapshot of Debian (from July 2014) and the status command works fine. I'm using python to code. I know that systemctl can throw output acording to journal formatting type:

systemctl status my_service -o cat

The best documentation of systemclt I've found is:
http://www.freedesktop.org/software/systemd/man/systemctl.html

But maybe it has something to do with on how the prinf is handling the stdout. I haven't been programming in C, but maybe you can try using fprintf(stdout, "Hello!");

I have no ideia if it is going to work, but is worth trying.

hi there

for my project I have been wrapping my systemd services using the Linux screen command.

You can then reattach to them from a shell and thus read all system.out (and also interact with them using a CLI).

http://linux.die.net/man/1/screen

to install:
sudo apt-get install screen

so, for example, I use the following to start some java code

in ./run-java.sh
              
screen -dmS javaclient java -server -jar test-client.jar 10.0.1.5

this run the code & then detaches the CLI as a screen titled javaclient

I can then start this script using systemd

to reattach:

screen -R javaclient

to subsequently detach:

ctrl-a d

more info

https://www.mattcutts.com/blog/a-quick-tutorial-on-screen/

https://www.mattcutts.com/blog/screen-power-tips-screenrc/

Haha, that’s definitely a creative solution! I’ve used screen in the past quite a bit and switched to tmux, which seems to be installed by default. Doesn’t matter for the situation you’re using it in but it’s definitely better.

For now I’m just ignoring it. I’m not at all sure why the output of my program isn’t going anywhere. You would think systemd-journalctl would catch it but it doesn’t seem to. Oh well, I’ll have to debug later.

-Devin

The output of stderr error can be found using “sudo systemctl status SERVICE_NAME.service”; I’m not sure where stdout is going (perhaps /dev/null?). Irrespective, when doing systemd development, I always “tee” both stdout and stderr into a log file under my home directory. By using tee, I see the stdout when running with a debugger, and it is also logged when running at startup. Since I have standardized on using python for all scripts (whenever possible), this is relatively simple using the imported sys module (I can post if there is interest and someone can explain simply how to include code in a post).

You realize you’re responding to a post that is nearly a year old ? On Christmas of all days . . .

Merry Christmas, and go sit down and relax with the family . . .

No, I didn’t realize the date of the post, just had some time for browsing (in between family interactions) and thought I might be able to offer some suggestions. I see you are also browsing on Christmas at dinner time. Thank you for your suggestions on how I can improve my life; it’s always nice to get positive constructive criticisms, although they don’t seem to have much to do with the technical matter. Perhaps you could enlighten me with the rules of posting?

There is only one rule, the rule of life. Get one.