【问题标题】:Redis does not start automaticallyRedis 没有自动启动
【发布时间】:2019-01-07 02:36:45
【问题描述】:

我有一个使用 Redis 数据库的 ReactJS 网络应用程序。我正在使用 Ubuntu 16.04 在两台不同的计算机上部署我的系统。 但是,我可以使服务器在一台计算机上以npm start 运行而不会出现任何错误,但在另一台计算机上,当我使用npm start 时 它提示我这个错误:

Redis connection to localhost:6379 failed - connect ECONNREFUSED

因此,为了避免该错误,我需要使用 redis-server 手动启动 Redis,但我不想这样做。在网上搜索答案,但找不到合适的解决方案。所以这是我最后的机会。感谢阅读^^

【问题讨论】:

    标签: javascript redis


    【解决方案1】:

    您需要在 npm 启动脚本中添加脚本以启动 redis-server。这是示例代码 -

    {
      "name": "test app",
      "version": "1.0.0",
      "scripts": {
        "start": "sh redis-start-script.sh && **your start script**"   
      }
    }
    

    你可以参考这个answer

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-26
      • 2012-08-05
      • 2012-11-04
      • 1970-01-01
      • 1970-01-01
      • 2021-12-26
      • 1970-01-01
      • 2020-12-18
      相关资源
      最近更新 更多