MusicBot: Bot won't read config.txt file when starting through systemctl on Ubuntu Server 16.04 LTS
General Troubleshooting
Please check off these steps before suggesting a feature or reporting a bug:
- I am running the latest version:
- I have followed all instructions on the setup page (and if applicable, Raspberry Pi)
- I have read through the planned and suggested features
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'.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 15 (5 by maintainers)
Wasn’t looking the the correct directory I fixed this issue by adding 2 lines under the service file
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