首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >处理couchdb通知的外部进程导致崩溃

处理couchdb通知的外部进程导致崩溃
EN

Stack Overflow用户
提问于 2015-10-25 00:10:44
回答 2查看 226关注 0票数 2

我很难通过python脚本处理couchdb数据库的更改。

代码语言:javascript
运行
复制
data = 'test'
f = open('/home/username/test','w')
f.write(data + '\n')
f.close()

这是我尝试运行的脚本(用于测试目的)。它被称为"list.py“,它位于"/usr/local/src/couchdb”中。我在"/etc/couchdb“文件夹中修改"local.ini”,添加:

代码语言:javascript
运行
复制
[update_notification]
list = python /usr/local/src/couchdb/list.py

每次修改时都应该调用这个脚本,但是它会导致couchdb几乎一启动服务器就崩溃。这是错误的日志(我想)。

代码语言:javascript
运行
复制
 [Sat, 24 Oct 2015 23:05:09 GMT] [error] [<0.6468.0>] {error_report,<0.31.0>,
                  {<0.6468.0>,crash_report,
                   [[{initial_call,
                      {couch_os_process,init,['Argument__1']}},
                     {pid,<0.6468.0>},
                     {registered_name,[]},
                     {error_info,
                      {exit,
                       {exit_status,1},
                       [{gen_server,terminate,6,
                         [{file,"gen_server.erl"},{line,744}]},
                        {proc_lib,init_p_do_apply,3,
                         [{file,"proc_lib.erl"},{line,239}]}]}},
                     {ancestors,
                      [couch_db_update,couch_primary_services,
                       couch_server_sup,<0.32.0>]},
                     {messages,[]},
                     {links,[<0.5922.0>]},
                     {dictionary,[]},
                     {trap_exit,false},
                     {status,running},
                     {heap_size,987},
                     {stack_size,27},
                     {reductions,884}],
                    []]}}

 [Sat, 24 Oct 2015 23:05:09 GMT] [error] [<0.5922.0>] Update notification 
 process <0.6468.0> died: {exit_status,

 [Sat, 24 Oct 2015 23:05:09 GMT] [error] [<0.6430.0>] {error_report,<0.31.0>,
                  {<0.6430.0>,supervisor_report,
                   [{supervisor,{local,couch_db_update_notifier_sup}},
                    {errorContext,child_terminated},
                    {reason,normal},
                    {offender,
                     [{pid,<0.6467.0>},
                      {name,"list"},
                      {mfargs,
                       {couch_db_update_notifier,start_link,
                        ["python /usr/local/src/couchdb/list.py"]}},
                      {restart_type,permanent},
                      {shutdown,1000},
                      {child_type,supervisor}]}]}}

 [Sat, 24 Oct 2015 23:05:09 GMT] [error] [<0.6472.0>] ** Generic server <0.6472.0> terminating 
** Last message in was {#Port<0.5590>,{exit_status,1}}
** When Server state == {os_proc,"python /usr/local/src/couchdb/list.py",
                             #Port<0.5590>,
                             #Fun<couch_os_process.2.14837184>,
                             #Fun<couch_os_process.3.14837184>,5000}
** Reason for termination == 
** {exit_status,1}

我遗漏了什么?非常感谢

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-11-05 17:26:26

因此,在couchdb中处理通知的外部进程似乎需要一个无限循环,每次读取stdin,否则就不能工作。

代码语言:javascript
运行
复制
import sys

line = str(sys.stdin.readline())
while line:
    print(line)
    line = sys.stdin.readline()

例如,这个代码(python)读取每个通知并打印它..。

票数 2
EN

Stack Overflow用户

发布于 2015-10-25 00:26:26

couchdb进程是否有权读取/写入脚本中的文件?它可能是您拥有的,couchdb进程可能没有写它的权限。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33324729

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档