Re: [PATCH] Add start- stop- box/smsc, store-status functionality to debian init script
Konstantin Vayner <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <CAFvzOVyqqVG+n=3wiyOSR3+kA7cMP46=GxV_gbqbkpm=ouUe-A@mail.gmail.com> |
Ok, here's what i've got so far...
Sending the file rather than the patch, because basically this is almost a
complete rewrite.
New vs the previous (patch) version:
1. Added wait for ports on start / shutdown (up until configurable timeout,
default is set to 2 minutes, as Alexander suggested).
2. On shutdown, if port wait reaches timeout, it resorts to killing
bearerbox...
and that - in 3 phases: (1) send SIGABRT, (2) send SIGTERM and finally
(3) send SIGKILL
3. added checks for root where it is relevant (when starting/stopping the
gateway or individual boxes).
4. added check that lynx exists
5. when kannel is down, print a nice message instead of lynx error message
that it is unable to reach admin url
6. moved some parts to functions so they are reusable (like, for example,
box_up that checks if a box is up and running) and hopefully more
human-readable.
7. added more commands: suspend, resume, box-status
8. added two non-standard (but widely used) boxes - smppbox and sqlbox into
start/stop and config cases
9. added ability to run multi-instance boxes (eg sqlbox1, sqlbox2), but
this will require editing the file to get it up and running (left example
blocks to hint how this should be done).
Btw, can anyone please elaborate on why do you need to run multiple
smsboxes / sqlboxes on same machine?
And now that i think of it, this script also won't support running separate
boxes on different machines (because the start/stop sequence as well as
port and process pid checks assume all boxes are run locally).
Please, review.
Comments appreciated ;)
Regards,
Konstantin
On Tue, Mar 12, 2013 at 12:27 PM, Alexander Malysh <[email protected]>wrote:
> I would suggest to wait for 2 minutes, because I saw some buggy SMSCs that
> didn't accept unbind pdu.
>
> If then bearerbox still running you can send SIGABRT to the process, this
> ensure that Kannel cleanups pid files.
>
> Alex
>
> Am 12.03.2013 um 10:33 schrieb Konstantin Vayner <[email protected]>:
>
> Looking at your init script;
> I can merge these together
>
> Question is - what if bearerbox is stuck and does not shut down?
> I've ran across this before with ucp smscs that were not letting go ;)
>
> Regards,
> Konstantin
>
>
> On Tue, Mar 12, 2013 at 11:25 AM, spameden <[email protected]> wrote:
>
>> 2013/3/12 Alexander Malysh <[email protected]>:
>> > Hi,
>> >
>> > patch not tested but the idea is good and I'm +1 to commit it.
>> >
>> > Any objections?
>> >
>> > Alex
>> >
>> > Am 12.03.2013 um 00:09 schrieb Konstantin Vayner <[email protected]>:
>> >
>> >> This adds some new features to debian init script:
>> >>
>> >> 1. Allow start/stop separate boxes via /etc/init.d/kannel
>> {start|stop}-box boxname
>>
>> Nice idea, but needs better handling, I've looked into the patch it
>> seems does not support multiple configuration files (for example for
>> starting multiple smsbox'es or sqlbox'es, e.g.
>> /etc/kannel/sqlbox1.conf /etc/kannel/sqlbox2.conf, etc)
>>
>> >> 2. Allow start/stop smsc by /etc/init.d/kannel {start|stop}-smsc
>> smsc-id
>> >> 3. Allow querying store status via /etc/init.d/kannel store-status
>> >> 4. Actually, it also allows arbitrary http admin commands via
>> /etc/init.d/kannel http-admin command params , where params should be a
>> single-argument string, prepared to be passed via url (in form
>> "param1=value¶m2=value")
>>
>> Would be nice to require/chacking of lynx installation before giving
>> any of the opportunity to execute those commands.
>>
>> >>
>> >> NB: startup/shutdown output format changed to multiple lines of output
>> here (because it uses start-box / stop-box internally, and each call like
>> that outputs a line)
>>
>> The main problem with current init.d script it's not always working.
>>
>> If there was a big queue on the restart bearerbox takes some time to
>> populate the memory with it, thus
>>
>> sleep 1 is not enough anymore.
>>
>> I'm using this solution on the start:
>>
>> PORTCONF=$(grep '^smsbox-port' ${CONF}|awk {'print $3'})
>> while [ -z "$(netstat -nl|grep ":${PORTCONF}.*LISTEN")" ]; do sleep 1;
>> done
>>
>> and on stop:
>>
>> while [ ! -z "$(netstat -nl|grep ":${PORTCONF}.*LISTEN")" ]; do sleep 1;
>> done
>>
>>
>> My version also handles multiple sqlbox.conf files depending on the
>> values in the /etc/default/kannel file for debian.
>>
>> So if you don't want to start specific service (e.g. OpenSMPPBox, you
>> just change value from 1 to 0 for START_SMPPBOX in the
>> /etc/default/kannel).
>>
>> I've attached my init.d script and default file for understanding.
>> >>
>> >> Attached.
>> >>
>> >> Regards,
>> >> Konstantin
>> >> <debian_kannel_init.patch>
>> >
>> >
>>
>
>
>
kannel.init
(application/octet-stream, 8.4 KB) - not displayed