Open GoogleCodeExporter opened 9 years ago
When I use a system cron scheduled job with @reboot to launch the webrtc2sip,
and reboot the server with out logging in, the system seems to work fine.
I attempted the following init script, but it did not work for me.
====================================
Original comment by sdellu...@gmail.com
on 22 Apr 2013 at 1:22
Attachments:
Here's my attempt to create an init script. It assumes a webrtc2sip system user
which can be created with:
adduser --quiet --system --group --disabled-password --shell /bin/false --gecos
"webrtc2sip" --home /var/run/webrtc2sip webrtc2sip
It also assumes that screen is installed. This script works for me but it's not
heavily tested and needs some more work.
Jeremy
Original comment by autosta...@gmail.com
on 24 Apr 2013 at 2:07
Attachments:
And you need a file /etc/default/webrtc2sip. I've attached an example.
Original comment by autosta...@gmail.com
on 24 Apr 2013 at 2:25
Attachments:
[deleted comment]
Jeremy
I just started to observe the high CPU consumption issue your indicated.
Your script seems to work MUCH better :) THANK YOU!
HOWEVER, its still not starting up on server reboot... I ended up putting again
into the crontab
@reboot service webrtc2sip start
and now it works.
I was under the impression it should work automatically if it was in the
/etc/init.d/ folder, but it does not seem to start up on its own .
Original comment by sdellu...@gmail.com
on 15 May 2013 at 5:22
Hello Steve,
In order for services to start you need to tell them when to start (i.e. in
which runlevel). On Ubuntu this is done with the update-rc.d command:
update-rc.d webrtc2sip defaults
This will set up the webrtc2sip init script to run at boot time.
Jeremy
Original comment by autosta...@gmail.com
on 15 May 2013 at 8:37
Thanks Jeremy!
I will try it now.
Also,
I wonder if there is some way to enhance the startup script to make sure that
there are no left over TCP connections.... I find that between restarting the
webrtc2sip software, I need to wait a few mins for the sessions to close....
webrtc2sip throws many errors when you try to start it if there are left over
connections.
Perhaps adding a loop and wait for the results of
netstat -t | grep 10060
to be non could help?
thanks again
Original comment by sdellu...@gmail.com
on 15 May 2013 at 7:44
Isn't this solved with the 2.5.0 release of webrtc2ip (r85)?
That release fixes issue 13:
http://code.google.com/p/webrtc2sip/issues/detail?id=13
Or is that a different issue?
Jeremy
Original comment by autosta...@gmail.com
on 16 May 2013 at 11:44
I am currently running with 2.5.0. How rapidly should these connections be
brought down after termination of webrtc2sip? I still receive these messages
and observe connections still waiting to time out....
If I check netstat -t | grep 10060, I can see several connections still active
after quitting the application... if I wait long enough, the connections time
out, and I can restart without issue. I usually need to wait less than a
minute.... but when you are testing different configurations ...typically
starting and stopping frequently, its annoying :) ... in a real usage scenario,
I assume you would not be starting and stopping and starting again in such
rapid succession however. Still this small check could be helpful on startup.
thanks!
***ERROR: function: "tnet_socket_create_2()"
file: "src/tnet_socket.c"
line: "157"
MSG: bind to [173.254.255.48:10060]have failed
***ERROR: function: "tnet_socket_create_2()"
file: "src/tnet_socket.c"
line: "157"
MSG: (SYSTEM)NETWORK ERROR ==>Address already in use
***ERROR: function: "tnet_socket_create_2()"
file: "src/tnet_socket.c"
line: "184"
MSG: Invalid socket.
***ERROR: function: "tnet_socket_create_2()"
file: "src/tnet_socket.c"
line: "184"
MSG: (SYSTEM)NETWORK ERROR ==>Address already in use
***ERROR: function: "tnet_transport_create()"
file: "src/tnet_transport.c"
line: "155"
MSG: Failed to create master socket
***ERROR: function: "_tnet_transport_ssl_init()"
file: "src/tnet_transport.c"
line: "61"
MSG: Invalid parameter
***ERROR: function: "tnet_transport_create()"
file: "src/tnet_transport.c"
line: "160"
MSG: Failed to initialize TLS and/or DTLS caps
***ERROR: function: "tsk_runnable_set_priority()"
file: "src/tsk_runnable.c"
line: "180"
MSG: Invalid parameter
***ERROR: function: "tsip_stack_start()"
file: "src/tsip.c"
line: "728"
MSG: Failed to add new transport
*INFO: SIP STACK::run -- STOP
***ERROR: function: "start()"
file: "mp_engine.cc"
line: "537"
MSG: Failed to start SIP stack
Original comment by sdellu...@gmail.com
on 17 May 2013 at 3:18
Jeremy
"update-rc.d webrtc2sip defaults"
Yes that resolved my statup issue with the init script
thanks!
Original comment by sdellu...@gmail.com
on 17 May 2013 at 3:26
Hello Steve,
If there are no active TCP connections on 10060, immediately. If there
are active connections it could take up to minute.
I always make sure I kill all active connections (so any browsers
connected via WebSocket to webrtc2sip) before I restart webrtc2sip. But
I'll see if I can add an extra check to the init script.
Jeremy
Original comment by autosta...@gmail.com
on 17 May 2013 at 8:34
You can actually adjust the length of the TIME_WAIT state. By default it's 60
seconds:
cat /proc/sys/net/ipv4/tcp_fin_timeout
60
You could try setting tcp_fin_timeout to a lower setting to shorten the length
of the TIME_WAIT state:
echo -n 20 > /proc/sys/net/ipv4/tcp_fin_timeout
There are also tools like tcpkill and cutter that allow you to terminate active
connections but afaik then you'll still have to deal with the TIME_WAIT state
in the case of webrtc2sip.
Jeremy
Original comment by autosta...@gmail.com
on 17 May 2013 at 9:44
An option would be to issue a tcpkill or cutter command before restarting
webrtc2sip. I'm going to test this. So basically you terminate the WebSocket
connections on the server side and then you restart webrtc2sip with no active
connections so webrtc2sip should start immediately again.
Jeremy
Original comment by autosta...@gmail.com
on 17 May 2013 at 9:47
Thanks Jeremy!
Your init.d script (the one attached to this incident) is working very well for
me.
I made a small enhancement by adding a function to wait for the ports to be
available on restart. See the function below and the fully modified script
attached.
Perhaps you may consider to add this to your package?
Also, I attempted to use your latest PPA update with the init script using
SCREEN... however, I was not successful ... perhaps I do not really understand
how the SCREEN function works.
thanks again!!
Steve
#-------------------------------------------------------------------------------
---------------------------------------------
SLEEP_TIME=15
DEFAULT_FILE=/etc/default/webrtc2sip
DEFAULT_CONFIG=/etc/webrtc2sip/config.xml
CMD_OUTPUT="/usr/bin/logger -s"
CMD_GREP=/bin/grep
CMD_SLEEP=/bin/sleep
CMD_CUT=/usr/bin/cut
#-------------------------------------------------------------------------------
---------------------------------------------
WaitForPorts ()
{
strConfigFile=`${CMD_GREP} -v "#" ${DEFAULT_FILE} | ${CMD_GREP} "OPTIONS=--config=" | ${CMD_CUT} -f3 -d =`
if [ -z "${strConfigFile}" ]; then
strConfigFile=${DEFAULT_CONFIG}
fi
${CMD_OUTPUT} "$0>...Default=[${DEFAULT_FILE}] Config=[${strConfigFile}]"
strTransports=`${CMD_GREP} "<transport>" ${strConfigFile}`
if [ -n "${strTransports}" ]; then
for Transport in ${strTransports}
do
Port=`echo ${Transport} | ${CMD_CUT} -f2 -d '>' | ${CMD_CUT} -f1 -d '<' | ${CMD_CUT} -f3 -d ';'`
# ${CMD_OUTPUT} "$0>...Testing port=${Port}"
while [ -n "`netstat -t | ${CMD_GREP} ":${Port}"`" ]
do
${CMD_OUTPUT} "$0>...Starting webRTC2SIP... Waiting another ${SLEEP_TIME} seconds for port: ${Port} to be available"
${CMD_SLEEP} ${SLEEP_TIME}
done
done
fi
${CMD_OUTPUT} "$0>...STARTING...."
}
#-------------------------------------------------------------------------------
---------------------------------------------
Original comment by sdellu...@gmail.com
on 17 May 2013 at 6:04
Attachments:
Thanks, this looks great. I've been trying to work on an upstart version but
the results were mixed.
Quick question: does this init config also handle respawning? I've seen
webrtc2sip crashing on some random occasions (albeit rarely).
Thanks!
Original comment by ciprian....@gmail.com
on 21 May 2013 at 4:39
It doesn't handle respawning. You could use a tool like monit for this.
Original comment by autosta...@gmail.com
on 22 May 2013 at 8:52
Original comment by boss...@yahoo.fr
on 24 May 2013 at 1:45
When checking the process status with
service webrtc2sip status
I was having an issue with sometimes running into the condition of
Status of webrtc2sip: webrtc2sip: is not running but
/var/run/webrtc2sip/webrtc2sip.pid exists.
To improve this condition, I updated the case section to remove the PID file
and update it if it is actually running. See the update below and the full
file attached. Thanks!
status)
${CMD_OUTPUT} "$0>...Status of ${DESC}: ${NAME} "
if [ ! -r "${PIDFILE}" ]; then
${CMD_OUTPUT} "$0>...is not running."
exit 3
fi
if read pid < "$PIDFILE" ; ps -p "$pid" > /dev/null 2>&1; then
${CMD_OUTPUT} "$0>...is running."
exit 0
else
${CMD_OUTPUT} "$0>...${PIDFILE} exists...But does not contain valid PID...REMOVING ${PIDFILE}"
rm ${PIDFILE}
strActualPID=`${CMD_PIDOF} ${NAME}`
if [ -n "${strActualPID}" ]; then
${CMD_OUTPUT} "$0>...${NAME} is running with PID = ${strActualPID}... so updating PID file ${PIDFILE}"
echo ${strActualPID} > ${PIDFILE}
exit 0
fi
exit 1
fi
;;
Original comment by sdellu...@gmail.com
on 25 May 2013 at 8:04
Attachments:
Small updates to the init.d script attached
Original comment by sdellu...@gmail.com
on 28 May 2013 at 5:03
Attachments:
Hi Jeremy and Steve,
Follownig this thread, I have created the system user by:
sudo adduser --system --group --disabled-password --shell /bin/false --gecos
"webrtc2sip" --home /var/run/webrtc2sip webrtc2sip
and deployed your corresponding files as /etc/init.d/webrtc2sip and
/etc/default/webrtc2sip
Unfortunately, I did not manage to have the script /etc/init.d/webrtc2sip
running successfully. At the command line, webrtc2sip can work via:
$ sudo start-stop-daemon --start --verbose --chuid root:root --exec
/usr/bin/screen -- -dmS webrtc2sip /usr/local/sbin/webrtc2sip
--config=/usr/local/etc/webrtc2sip/config.xml
Starting /usr/bin/screen...
$ ps aux | grep webrtc2sip
root 28711 0.0 0.0 31268 1360 ? Ss 15:19 0:00
/usr/bin/SCREEN -dmS webrtc2sip /usr/local/sbin/webrtc2sip
--config=/usr/local/etc/webrtc2sip/config.xml
root 28712 0.1 0.2 669668 5676 pts/2 Ssl+ 15:19 0:00
/usr/local/sbin/webrtc2sip --config=/usr/local/etc/webrtc2sip/config.xml
jchan 28727 0.0 0.0 9392 916 pts/1 S+ 15:19 0:00 grep
--color=auto webrtc2sip
However, if I replace root with webrtc2sip, the process is not running via the
command line interface:
$ sudo start-stop-daemon --start --verbose --chuid webrtc2sip:webrtc2sip --exec
/usr/bin/screen -- -dmS webrtc2sip /usr/local/sbin/webrtc2sip
--config=/usr/local/etc/webrtc2sip/config.xml
Starting /usr/bin/screen...
$ ps aux | grep webrtc2sip
jchan 28708 0.0 0.0 9388 920 pts/1 S+ 15:18 0:00 grep
--color=auto webrtc2sip
Wondering if my webrtc2sip user and group properties are set correctly, or I
should not debug this issue via the command line at all?
Thanks for your help.
Original comment by connect....@gmail.com
on 22 Oct 2013 at 4:31
Hi,
has anybody managed to have a working init.d script on Centos6? I compiled
start-stop-daemon on Centos, after starting the init.d script it shows:
"webrtc2sip is running with PID = 27972... so updating PID file
/var/run/webrtc2sip/webrtc2sip.pid"
but no screen nor webrtc are running. May it be related to the webrtc2sip user?
Thank you
Original comment by peter.s...@gmail.com
on 27 Jan 2014 at 11:44
Hi,
I am running on Ubuntu 12.04 and this init.d script is not working for me. It
tries to start, then either says it failed to start or that the pid file
already exists. The process never actually get's a PID or starts. Not sure what
is wrong. The server runs fine when I manually execute it. How can this script
be debugged?
thank you
Original comment by ops...@gmail.com
on 17 May 2015 at 12:47
Original issue reported on code.google.com by
autosta...@gmail.com
on 15 Apr 2013 at 1:56