【问题标题】:How to start my telegram bot on Google Cloud如何在 Google Cloud 上启动我的电报机器人
【发布时间】:2021-12-16 11:21:35
【问题描述】:

我想将我的机器人上传到服务器。我正在使用谷歌云。我的bot.service 文件如下所示:

[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

当我输入以下命令时:

sudo systemctl daemon-reload
sudo systemctl enable bot
sudo systemctl start bot
sudo systemctl status bot

我收到以下错误:

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'.

如果您使用/home/python3/ConverterBot/main.py 命令启动机器人,那么一切正常。查了好几遍:这个文件的路径存在,但是为什么报错说这个文件不存在?

【问题讨论】:

    标签: python telegram daemon python-daemon


    【解决方案1】:

    如果突然有人遇到这样的问题,那么解决方法如下:/home/misha_markov1015@converterbot/ConverterBot这个路径真的不存在。相反,您必须写:/home/misha_markov1015/ConverterBot。

    【讨论】:

      猜你喜欢
      • 2022-11-14
      • 2019-04-03
      • 2017-08-18
      • 2019-01-08
      • 2017-09-24
      • 1970-01-01
      • 2018-02-03
      • 2016-08-15
      • 1970-01-01
      相关资源
      最近更新 更多