簡體   English   中英

處理 couchdb 通知的外部進程導致崩潰

[英]External process to handle couchdb notification causes crash

我無法通過 python 腳本處理我的 couchdb 數據庫的更改。

data = 'test'
f = open('/home/username/test','w')
f.write(data + '\n')
f.close()

這是我嘗試運行的腳本(用於測試目的)。 它稱為“list.py”,位於“/usr/local/src/couchdb”中。 我修改了“/etc/couchdb”文件夾中的“local.ini”,添加:

[update_notification]
list = python /usr/local/src/couchdb/list.py

每次進行修改時都應調用此腳本,但是它幾乎在我啟動服務器時就會導致 couchdb 崩潰。 這是錯誤的日志(我認為)。

 [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}

我錯過了什么? 非常感謝

因此,在 couchdb 中處理通知的外部進程似乎需要一個無限循環,每次出現時都會讀取 stdin,否則它不起作用。

import sys

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

例如這段代碼(python)讀取每個通知並打印出來......

couchdb 進程是否有權讀/寫腳本中的文件? 它可能歸您所有,並且 couchdb 進程可能無權寫入它

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM