Gentoo Archives: gentoo-user-ru

From: Sergey Kobzar <sergey.kobzar@××××.ru>
To: gentoo-user-ru@l.g.o
Subject: Re: [gentoo-user-ru] Два инстанса Sphinx
Date: Fri, 07 Jun 2013 12:45:04
Message-Id: 51B1D5C8.3070901@mail.ru
In Reply to: [gentoo-user-ru] Re: [gentoo-user-ru] Re: [gentoo-user-ru] Re: [gentoo-user-ru] Re: [gentoo-user-ru] Re: [gentoo-user-ru] Re: [gentoo-user-ru] Re: [gentoo-user-ru] Два инстанса Sphinx by Sergey Kobzar
1 On 06/07/13 11:28, Sergey Kobzar wrote:
2
3 > Угу. Это я ошибся изначально.
4 > Тестирую. Думаю сегодня будет готово.
5
6 Вот что получилось:
7
8 /etc/init.d/searchd:
9
10 #!/sbin/runscript
11
12
13
14 cnffile="/etc/sphinx/sphinx`echo ${SVCNAME} | sed 's/searchd//'`.conf"
15 command="/usr/bin/searchd"
16 command_args="--config ${cnffile}"
17 pidfile="/run/${SVCNAME}.pid"
18
19
20 depend() {
21 need net
22 use logger
23 }
24
25 checkconfig() {
26 if [ ! -f ${cnffile} ]; then
27 eerror "Please create ${cnffile}"
28 eerror "Sample conf: /etc/sphinx/sphinx.conf.dist"
29 return 1
30 fi
31 return 0
32 }
33
34 start() {
35 checkconfig || return $?
36
37 ebegin "Starting sphinx searchd"
38 start-stop-daemon --start --pidfile ${pidfile} --exec
39 ${command} -- ${command_args}
40 eend $? "Failed to start sphinx searchd"
41 }
42
43 stop() {
44 ebegin "Stopping sphinx searchd"
45 start-stop-daemon --stop --pidfile ${pidfile} --exec ${command}
46 --retry 180
47 eend $? "Failed to stop sphinx searchd"
48 }
49
50
51 /etc/logrotate.d/sphinx ротации log-файлов для нескольких инстансов:
52
53 /var/log/sphinx/*.log {
54 create 644
55 missingok
56 sharedscripts
57 postrotate
58 find /run/ -maxdepth 1 -type f -name 'searchd*' | \
59 while read pidfile; do
60 kill -USR1 `cat ${pidfile}`
61 done
62 endscript
63 }
64
65
66 Ну и в ebuild добавить что-то типа:
67
68 pkg_postinst() {
69 einfo "If you want to run multiple Sphinx instances:"
70 einfo "- make a link of /etc/init.d/searchd"
71 einfo "- create a copy of /etc/sphinx/sphinx.conf with appropriate name"
72 einfo "- Change listen, log, query_log, pid_file and binlog_path in new
73 conf file"
74 einfo "- Start new instance using appropriate rc script (link)"
75 }
76
77
78 если нет существенных замечаний, я выкладываю все это дело на
79 bugs.gentoo.org.

Replies

Subject Author
Re: [gentoo-user-ru] Два инстанса Sphinx Sergey Popov <pinkbyte@g.o>