I want to upload my bot to the server. I am using Google Cloud. My bot.service file looks like this:
[Unit]
Description=Telegram bot 'ConverterBot'
After=syslog.target
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/home/misha_markov1015@converterbot/ConverterBot
ExecStart=/usr/bin/python3 /home/misha_markov1015@converterbot/ConverterBot/main.py
RestartSec=10
Restart=always
[Install]
WantedBy=multi-user.target
When I enter the following commands:
sudo systemctl daemon-reload
sudo systemctl enable bot
sudo systemctl start bot
sudo systemctl status bot
I get the following error:
Nov 01 19:08:53 converterbot systemd[1]: Started Telegram bot 'ConverterBot'.
Nov 01 19:08:53 converterbot systemd[8978]: bot.service: Changing to the requested working directory failed: No such file or directory
Nov 01 19:08:53 converterbot systemd[8978]: bot.service: Failed at step CHDIR spawning /usr/bin/python3: No such file or directory
Nov 01 19:08:53 converterbot systemd[1]: bot.service: Main process exited, code=exited, status=200/CHDIR
Nov 01 19:08:53 converterbot systemd[1]: bot.service: Failed with result 'exit-code'.
If you start the bot with the /home/python3/ConverterBot/main.py command, then everything works correctly. I checked several times: the path to this file exists, but why does the error say that this file does not exist?
If suddenly someone encounters such a problem, then the solution was as follows:
/home/misha_markov1015@converterbot/ConverterBotthis path really does not exist. Instead, you had to write:/home/misha_markov1015/ConverterBot.