errbotio / errbot

Errbot is a chatbot, a daemon that connects to your favorite chat service and bring your tools and some fun into the conversation.
http://errbot.io
GNU General Public License v3.0
3.13k stars 615 forks source link

my errbot cannot start as daemon, it always shutdown automatic #1616

Closed ljhmily closed 1 year ago

ljhmily commented 1 year ago

Describe the bug my errbot cannot start as daemon, it always shutdown automatic

To Reproduce start with errbot -d -c config.py, and then it start my port, then shutdown it, the logs like this image the console mode start is right

Expected behavior start normal.

Screenshots If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

Additional context Add any other context about the problem here.

nzlosh commented 1 year ago

The text backend expects to run in an interactive shell where you can type commands directly to the bot via the console. Running errbot as a daemon detaches from stdin/stdout and stderr, which causes the text backend to shutdown because it can't read from stdin. This is by design and not a bug since running the text backend in the background prevents interaction with it.

If you want to be able to run errbot in background mode you should use the Null backend, which does not expect to have access to stdin/stdout/stderr.

ljhmily commented 1 year ago

The text backend expects to run in an interactive shell where you can type commands directly to the bot via the console. Running errbot as a daemon detaches from stdin/stdout and stderr, which causes the text backend to shutdown because it can't read from stdin. This is by design and not a bug since running the text backend in the background prevents interaction with it.

If you want to be able to run errbot in background mode you should use the Null backend, which does not expect to have access to stdin/stdout/stderr. emm,in the backend list, it not give the Null backend. i create some webapi as plugins, so even in text backend, i can use web api to get the interactive replies.

i have two server, and the python envirionment the same, the other one can be use text backend with backgroud mode, but this one cannot.

and, i tried the Null backend, it cannot reply my web query with the webrequests.

nzlosh commented 1 year ago

My understanding is the text backend can not run without an interactive shell. If you managed to do it on one server, you'll need to figure out what you did and do the same thing on the second server.

Failing that, I see two possible ways to get errbot working the way you seem to want:

  1. Use screen or tmux to start errbot in foreground mode with an interactive shell. (not a very clean solution, but it'd work)
  2. Write your own backend (maybe fork text backend and adapt it) that doesn't use to stdin.
ljhmily commented 1 year ago

the text backend is not necessary for me. my webapi is like this, but it cannot run as the Null backend, it cannot reply. image

nzlosh commented 1 year ago

errbot is designed first and foremost as a chat bot, not a web server. It might have a webserver integration, but that is not its core function or intended use case. If you want to attempt to use errbot as a webserver, you're free to do that, but the problems you're encountering are because of the way errbot is designed.

You might want to consider frameworks that are specifically designed for web server use cases (flask, bottle etc). If you insist on using errbot as a webserver, you will probably need to fork errbot and adapt the code to match your requirements.

ljhmily commented 1 year ago

errbot is designed first and foremost as a chat bot, not a web server. It might have a webserver integration, but that is not its core function or intended use case. If you want to attempt to use errbot as a webserver, you're free to do that, but the problems you're encountering are because of the way errbot is designed.

You might want to consider frameworks that are specifically designed for web server use cases (flask, bottle etc). If you insist on using errbot as a webserver, you will probably need to fork errbot and adapt the code to match your requirements.

got that,i Adjusted some code,the Null mode is ok now。

sijis commented 1 year ago

Errbot does have webhook functionality, as described in https://errbot.readthedocs.io/en/latest/user_guide/plugin_development/webhooks.html.

It's strongly suggested to not expose it directly but use it behind a real webserver, like nginx or apache.