question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bot won't read config.txt file when starting through systemctl on Ubuntu Server 16.04 LTS

See original GitHub issue

General Troubleshooting

Please check off these steps before suggesting a feature or reporting a bug:

Issue

Issue Type

  • Bug Report
  • Feature Request

Description

When starting MusicBot through systemctl the bot complains about no API Token being provided even though the config.txt has the API Token Entered

/etc/systemd/system/musicbot.service

[Unit]
Description=MusicBot

[Service]
ExecStart=/usr/bin/java -jar /opt/SpotifyChan/spotifychan.jar -nogui
Type=simple
User=root

[Install]
WantedBy=multi-user.target

The System Status Displays the following

● musicbot.service - MusicBot
   Loaded: loaded (/etc/systemd/system/musicbot.service; enabled; vendor pres
   Active: failed (Result: exit-code) since Mon 2018-05-21 14:00:02 UTC; 4min 55
 Main PID: 4070 (code=exited, status=1/FAILURE)

May 21 14:00:02 OrangeVM2 java[4070]: Bot Token:
May 21 14:00:02 OrangeVM2 java[4070]: Exception in thread "main" java.util.NoSuchElementException
May 21 14:00:02 OrangeVM2 java[4070]:         at java.util.Scanner.throwFor(Scanner.java:862)
May 21 14:00:02 OrangeVM2 java[4070]:         at java.util.Scanner.next(Scanner.java:1371)
May 21 14:00:02 OrangeVM2 java[4070]:         at com.jagrosh.jmusicbot.Config.prompt(Config.java:310)
May 21 14:00:02 OrangeVM2 java[4070]:         at com.jagrosh.jmusicbot.Config.<init>(Config.java:129)
May 21 14:00:02 OrangeVM2 java[4070]:         at com.jagrosh.jmusicbot.JMusicBot.main(JMusicBot.java:91)
May 21 14:00:02 OrangeVM2 systemd[1]: spotifychan.service: Main process exited, code=exited, status=1/FAILURE
May 21 14:00:02 OrangeVM2 systemd[1]: spotifychan.service: Unit entered failed state.
May 21 14:00:02 OrangeVM2 systemd[1]: spotifychan.service: Failed with result 'exit-code'.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
yosef022commented, May 21, 2018

Wasn’t looking the the correct directory I fixed this issue by adding 2 lines under the service file

[Unit]
Description=SpotifyChan

[Service]
WorkingDirectory=/opt/SpotifyChan
RootDirectory=/
ExecStart=/usr/bin/java -jar /opt/SpotifyChan/spotifychan.jar -nogui
Type=simple
User=root

[Install]
WantedBy=multi-user.target

If you don’t specify the WorkingDirectory and RootDirectory it uses the User’s default home which in this case the user ‘root’ doesn’t have a home directory so java was freaking out

0reactions
yosef022commented, May 21, 2018

Gimme just one second I’m gonna try something see if it’s not spitting out the full logs

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Welcome to emergency mode!" Think it is a fsck problem
I was able to mount ntfs partition sda3 but on restart Ubuntu was starting in emergency mode. To fix this issue, run the...
Read more >
I can't get the right items to boot on ubuntu-16.04 and systemd
I have no idea where ubuntu is deciding this. i can't find any config files that point to /sbin/nginx . No logs help....
Read more >
Ubuntu Server 20.04.3 LTS won't open a login shell on ...
for the RPi4B Ubuntu server install (or desktop install) the correct config.txt file to edit is located in the /boot/firmware directory.
Read more >
Ubuntu Server 16.04 systemctl service with python script is ...
After fiddling around i am at the point that the service is started via systemctl (and running) but the script is doing nothing......
Read more >
Ubuntu Manpage: systemd.service - Service unit configuration
If a service is requested under a certain name but no unit configuration file is found, systemd looks for a SysV init script...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found