我很难通过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}我遗漏了什么?非常感谢
发布于 2015-11-05 17:26:26
因此,在couchdb中处理通知的外部进程似乎需要一个无限循环,每次读取stdin,否则就不能工作。
import sys
line = str(sys.stdin.readline())
while line:
print(line)
line = sys.stdin.readline()例如,这个代码(python)读取每个通知并打印它..。
发布于 2015-10-25 00:26:26
couchdb进程是否有权读取/写入脚本中的文件?它可能是您拥有的,couchdb进程可能没有写它的权限。
https://stackoverflow.com/questions/33324729
复制相似问题