bmoscon / cryptofeed

Cryptocurrency Exchange Websocket Data Feed Handler
Other
2.14k stars 668 forks source link

System Exit received, faced by many users #979

Closed xiandong79 closed 1 year ago

xiandong79 commented 1 year ago

The cryptofeed instance stopped without any Error msgs

just like #893 , #858 , #889

I got

2023-06-05 06:41:59,035 : INFO : Config: use dict containing the following main keys: log
2023-06-05 06:41:59,036 : INFO : BINANCE_FUTURES: starting backend task CandlesPostgres with multiprocessing=False
2023-06-05 06:42:09,576 : INFO : FH: System Exit received - shutting down
2023-06-05 06:42:09,576 : INFO : FH: shutdown connections handlers in feeds

the script I use is what you write 2 years ago.

named candle_runner_1h_futures.py


import logging

from cryptofeed.feedhandler import FeedHandler
from cryptofeed.exchanges.binance_futures import BinanceFutures
from cryptofeed.defines import CANDLES
from cryptofeed.backends.postgres import CandlesPostgres
from cryptofeed.log import get_logger

from config import Config
from tools.common import get_symbols_exchange, get_log_volume

def main():
    cfg = Config()
    get_logger('candle_runner_1h', get_log_volume()+'candle_runner_1h.log', cfg.logging_level)
    LOG = logging.getLogger('candle_runner_1h')

    try:
        symbols = get_symbols_exchange(exchange='BINANCE_FUTURES')
        symbols = [symbol for symbol in symbols if "-PERP" in symbol]

        LOG.debug("Starting collection for symbols: %s", symbols)

        fh = FeedHandler(config = {'log': {'filename': get_log_volume()+'cf_1h.log', 'level': 'INFO'}})
        fh.add_feed(BinanceFutures(candle_closed_only=True, candle_interval='1h', subscription={CANDLES: symbols}, callbacks={CANDLES: CandlesPostgres(table="candles_hourly", host=cfg.postgres_host, user=cfg.postgres_user, pw=cfg.postgres_pass, port=cfg.postgres_port, db='postgres')}))
        fh.run()
    except Exception as e:
        LOG.error("FATAL - Encountered an exception in main - %s", str(e), exc_info=True)
        raise e

if __name__ == '__main__':
    main()

in this server, I also run the candle_runner.py BINANCE and ti_runner.py, all the scripts are written via you 2 years ago.

I just start the script in Ubuntu server, and the "candle_runner" and "ti_runner" running well for 1 month+, while "candle_runner_1h" stop automatically.

xiandong79 commented 1 year ago

I notice that other 3 coders reported the same issues, and the 3 issues are closed with answers.

xiandong79 commented 1 year ago

No people to login the server and execute "sudo kill candle_runner_1h" , or something else.

@xubinlaile @leonwang893 @yancong001

yancong001 commented 1 year ago

Yes, I had this problem, but I haven't had much of it since I ran it in the background with “nohup”.

xiandong79 commented 1 year ago

@yancong001

i still face this bug while I use

nohup python candle_runner_1h_futures.py > $PWD/logs/candles_1h.out 2>&1 &
xiandong79 commented 1 year ago
2023-06-05 06:41:39,769 : INFO : BINANCE_FUTURES: starting backend task CandlesPostgres with multiprocessing=False
2023-06-05 06:57:39,808 : WARNING : BINANCE_FUTURES.ws.2: received no messages within timeout, restarting connection
2023-06-05 06:57:49,812 : INFO : BINANCE_FUTURES.ws.2: closed connection 'WebSocketClientProtocol'
2023-06-05 08:56:04,109 : INFO : FH: System Exit received - shutting down
2023-06-05 08:56:04,109 : INFO : FH: shutdown connections handlers in feeds

after another run with 2 hours, it curshed

xiandong79 commented 1 year ago

I try to set

        fh.run(install_signal_handlers=False)

I do not know where the SystemExit comes