LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-02-2020, 06:07 PM   #1
MALDATA
Member
 
Registered: Mar 2005
Posts: 157

Rep: Reputation: 19
Debugging systemctl start hang


I have an application that needs to run as a service. So, I threw together a quick service file (myapp.service) that looks like this:

Code:
[Unit]
Description=My application
After=multi-user.target

[Service]
ExecStart=/usr/local/bin/MyApp
Type=simple
User=myuser
WorkingDirectory=/home/myuser
Restart=always
RestartSec=5
TimeoutStartSec=30

[Install]
WantedBy=multi-user.target
When I log in as myuser and run /usr/local/bin/MyApp from /home/myuser, it runs fine.

When I do "systemctl start myapp" however, it hangs until I ctrl-c. It doesn't print any output, and nothing goes to journalctl. It just sits there, well past the 30 second timeout. When I boot the system and SSH into it, the service is always listed as enabled but dead.

Anyone have some tips to debug this?

Here's the added weirdness... without getting too far into the weeds, this system gets created from a disk image. When I take that image and run it, this app and service file work fine! But if I take that image and run it through mender-convert, then the service behaves this way. So, I know the app and the service file are fine... but I have no way of debugging to figure out what systemctl is choking on in the mender image...
 
Old 06-04-2020, 08:48 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
I would add some logging into MyApp (into a specific file) and you will see if it was created at all.
Or just use strace on that app, not on systemctl.
 
Old 06-04-2020, 09:44 AM   #3
MALDATA
Member
 
Registered: Mar 2005
Posts: 157

Original Poster
Rep: Reputation: 19
I actually tried going even simpler and removing my application from the situation entirely. Now I just run a script:

Code:
#!/bin/bash

echo "This should go to stdout"
echo "This should go to myfile.txt" > ${HOME}/myfile.txt
The service file is pretty much the same:
Code:
[Unit]
Description=My Application
After=multi-user.target

[Service]
ExecStart=/home/myuser/testscript.sh
Type=simple
User=myuser
WorkingDirectory=/home/myuser
Restart=always
RestartSec=5
StandardOutput=file:/home/myuser/stdout.log
StandardError=file:/home/myuser/stderr.log

[Install]
WantedBy=multi-user.target
Still nothing. Running `systemctl start myapp.service` just sits there. No files get created in /home/myuser, stdout.log, stderr.log, myfile.txt, nothing.
 
Old 06-10-2020, 10:34 PM   #4
MALDATA
Member
 
Registered: Mar 2005
Posts: 157

Original Poster
Rep: Reputation: 19
Hi all,

After doing some digging, I found out the cause, but I'm still kinda surprised that there was no way to get more debugging information except guessing.

Basically, the image creation process ended up changing the owner of a bunch of directories. So, the default debian user became the owner of /, /lib, /lib/systemd, /lib/systemd/system, etc. I would expect that that would either affect all services or none of them, but that was what happened. Just finding those directories and setting them back to being owned by root fixed things up.

But to circle back to the real meat of the issue here... there was no information from systemd that anything was wrong, and trying to start the service just hung. I don't necessarily expect an error message from systemd that says "hey, a bunch of directories have weird ownership," but I'm surprised that there wasn't any output at all and that trying to start that service didn't outright fail. If something has gone haywire with systemd, is there any way to increase the verbosity or get more output, or anything?
 
Old 06-11-2020, 05:19 AM   #5
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,629

Rep: Reputation: Disabled
Kudos to you for finding that. I think you should mark this thread as solved and possibly start a new thread concerning output / verbosity of systemd...
 
  


Reply

Tags
systemd



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Failed to start mount-local.service: Unit not found. ( When trying to start the systemctl servive) lanz80 Linux - Server 1 06-29-2019 05:04 PM
Restart systemctl*daemon​ - systemctl command not found cjosephl Linux - Newbie 7 11-11-2017 04:53 PM
[SOLVED] Effective debugging or improving ones debugging skills Ajit Gunge Programming 3 05-22-2009 09:29 AM
Difference between kernel - debugging and application debugging topworld Linux - Software 2 03-30-2006 12:50 AM
Visual Debugging and Linux Kernel Debugging Igor007 Programming 0 09-30-2005 10:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration