having a strange behaviour.
Setup:
- Debian 11 server on Proxmox
- added user mupsje (modded for sudo)
- installed anaconda3 on mupsje and root.
- created env discordbot.
- directory: /home/mupsje/discordbot/
sh. file: on_startup.sh (chmodded)
#!/bin/bash
/home/mupsje/anaconda3/envs/discordbot/bin/python /home/mupsje/discordbot/bot.py
above line bot.py
#!/home/mupsje/anaconda3/envs/discordbot/bin/python
import blablabla
Now I want to start this env and the shell script when the server is reboot. When I login with credentials mupsje or root and test the shell script.
(base) mupsje@debian:$ cd /home/mupsje/discordbot/
(base) mupsje@debian:$ cd ~/discordbot$ ./on_startup.sh
Python scripts runs.
Now i'm trying to ad this in systemd as a service discordbot.service
[Unit]
Description=Startup Discordbot
[Service]
ExecStart=/home/mupsje/discordbot/on_startup.sh
[Install]
WantedBy=multi-user.target
when I start and status the systemctl service.
sudo systemctl start discordbot.service
sudo systemctl status discordbot.service
I get a error back and the python is not running.
* discordbot.service - Startup Discordbot
Loaded: loaded (/etc/systemd/system/discordbot.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2022-09-05 13:05:18 UTC; 9s ago
Process: 752 ExecStart=/home/mupsje/discordbot/on_startup.sh (code=exited, status=1/FAILURE)
Main PID: 752 (code=exited, status=1/FAILURE)
CPU: 355ms
Sep 05 13:05:18 debian on_startup.sh[753]: return future.result()
Sep 05 13:05:18 debian on_startup.sh[753]: File "/home/mupsje/anaconda3/envs/discordbot/lib/python3.10/site-packages/discord/client.py", line 817, in runner
Sep 05 13:05:18 debian on_startup.sh[753]: await self.start(token, reconnect=reconnect)
Sep 05 13:05:18 debian on_startup.sh[753]: File "/home/mupsje/anaconda3/envs/discordbot/lib/python3.10/site-packages/discord/client.py", line 745, in start
Sep 05 13:05:18 debian on_startup.sh[753]: await self.login(token)
Sep 05 13:05:18 debian on_startup.sh[753]: File "/home/mupsje/anaconda3/envs/discordbot/lib/python3.10/site-packages/discord/client.py", line 577, in login
Sep 05 13:05:18 debian on_startup.sh[753]: raise TypeError(f'expected token to be a str, received {token.__class__!r} instead')
Sep 05 13:05:18 debian on_startup.sh[753]: TypeError: expected token to be a str, received <class 'NoneType'> instead
Sep 05 13:05:18 debian systemd[1]: discordbot.service: Main process exited, code=exited, status=1/FAILURE
Sep 05 13:05:18 debian systemd[1]: discordbot.service: Failed with result 'exit-code'.
What I'm doing wrong?
regards Mupsje