【问题标题】:Calling remote gearman worker from local gearman client?从本地 Gearman 客户端调用远程 Gearman 工作人员?
【发布时间】:2015-02-09 10:05:03
【问题描述】:

可以从本地系统调用远程齿轮工吗?我尝试使用我的远程 azure 服务器 IP 进行呼叫:

本地系统上的客户端:

gm_client = gearman.GearmanClient(['204.43.9.41:4730'])
sent = sys.argv[1]
completed_job_request = gm_client.submit_job("load_db", sent)

远程工作者:

def __init__(self):
    self.gm_worker = gearman.GearmanWorker(['204.43.9.41:4730'])
    self.context = self.init_context()
    res = self.gm_worker.register_task('load_db', self.run_query)

当我让工作人员在远程服务器上运行并从本地客户端调用时,它给出了这个错误:

gearman.errors.ServerUnavailable: Found no valid connections: GearmanConnection 204.43.9.41:4730 connected=False

【问题讨论】:

    标签: python azure gearman python-gearman


    【解决方案1】:

    有一个非常简单的方法来做到这一点:

    1. 将 localhost gearman 端口与远程 gearman 端口绑定:

      sudo ssh -L 4730:localhost:4730 azureuser@servername.azurecloudapp.net

    2. 现在让工作人员在远程服务器上运行

    3. 从本地系统进行简单调用

      python worker.py 'input parameter'

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-05
      • 1970-01-01
      • 2019-03-25
      • 1970-01-01
      相关资源
      最近更新 更多