You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by "marcelo.m87" <ma...@gmail.com> on 2012/12/13 14:17:53 UTC
Re: Felix as a Daemon...
Hello everybody,
I have made my felix to execute in background, my daemon script is based on
linux initscripts and screen, being writed as follows:
#StartOf-osgid-------------------------------------------------------------------------------------
#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
DAEMON=OSGi
OSGI_HOME="/opt/OSGi"
FELIX_HOME="${OSGI_HOME}/felix-framework-4.0.3"
OSGI_REPO="${OSGI_HOME}/bundleRepo"
java="/opt/java/bin/java"
screen="/usr/bin/screen"
session_name="$DAEMON"
ARGS=""
pidof(){
echo $($screen -ls | grep "${session_name}" | awk '{print$1}' | sed
's/\.'"${session_name}"'//')
}
[ -r /etc/conf.d/$DAEMON ] && . /etc/conf.d/$DAEMON
PID=$(pidof)
start(){
stat_busy "Starting $DAEMON"
if [ -z "$PID" ]; then
cd "$FELIX_HOME"
${screen} -dmS "${session_name}" ${java} -jar bin/felix.jar "${OSGI_REPO}"
$ARGS
if [ $? = 0 ]; then
add_daemon $DAEMON
stat_done
else
stat_fail
exit 1
fi
else
echo -e "Already started or busy\nPIDs ${PID}"
stat_fail
exit 1
fi
}
case "$1" in
start)
start
;;
stop)
stat_busy "Stopping $DAEMON"
[ -n "$PID" ] && kill $PID &>/dev/null
if [ $? = 0 ]; then
rm_daemon $DAEMON
stat_done
else
stat_fail
exit 1
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
esac
#EndOf-osgid-------------------------------------------------------------------------------------
After installing this daemon, you would access felix CLI by the command
'screen -r OSGi' or if you have installed remote shell for felix, telnet
localhost 6666.
Best regards,
Marotta
--
View this message in context: http://apache-felix.18485.n6.nabble.com/Felix-as-a-Daemon-tp4835859p5001073.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org
Re: Felix as a Daemon...
Posted by Felix Meschberger <fm...@adobe.com>.
Hi Marotta,
Cool.
Do you (or others here) think it would be worth it distribute that script with the Felix main distro ?
If so, you might want to raise a JIRA [1] issue and attach the script.
Otherwise having a page on the wiki [2] would also be great. In this case you might want to file an issue with the text to be added to the wiki (since we cannot yet grant external access to the wiki).
Regards
Felix
[1] https://issues.apache.org/jira/browse/FELIX-3784
[2] https://cwiki.apache.org/confluence/display/FELIX/wiki
Am 13.12.2012 um 14:17 schrieb marcelo.m87:
> Hello everybody,
>
> I have made my felix to execute in background, my daemon script is based on
> linux initscripts and screen, being writed as follows:
> #StartOf-osgid-------------------------------------------------------------------------------------
> #!/bin/bash
>
> . /etc/rc.conf
> . /etc/rc.d/functions
>
> DAEMON=OSGi
> OSGI_HOME="/opt/OSGi"
> FELIX_HOME="${OSGI_HOME}/felix-framework-4.0.3"
> OSGI_REPO="${OSGI_HOME}/bundleRepo"
> java="/opt/java/bin/java"
> screen="/usr/bin/screen"
> session_name="$DAEMON"
> ARGS=""
>
> pidof(){
> echo $($screen -ls | grep "${session_name}" | awk '{print$1}' | sed
> 's/\.'"${session_name}"'//')
> }
>
> [ -r /etc/conf.d/$DAEMON ] && . /etc/conf.d/$DAEMON
>
> PID=$(pidof)
>
> start(){
> stat_busy "Starting $DAEMON"
> if [ -z "$PID" ]; then
> cd "$FELIX_HOME"
> ${screen} -dmS "${session_name}" ${java} -jar bin/felix.jar "${OSGI_REPO}"
> $ARGS
> if [ $? = 0 ]; then
> add_daemon $DAEMON
> stat_done
> else
> stat_fail
> exit 1
> fi
> else
> echo -e "Already started or busy\nPIDs ${PID}"
> stat_fail
> exit 1
> fi
> }
>
> case "$1" in
> start)
> start
> ;;
> stop)
> stat_busy "Stopping $DAEMON"
> [ -n "$PID" ] && kill $PID &>/dev/null
> if [ $? = 0 ]; then
> rm_daemon $DAEMON
> stat_done
> else
> stat_fail
> exit 1
> fi
> ;;
> restart)
> $0 stop
> sleep 1
> $0 start
> ;;
> *)
> echo "usage: $0 {start|stop|restart}"
> esac
> #EndOf-osgid-------------------------------------------------------------------------------------
>
> After installing this daemon, you would access felix CLI by the command
> 'screen -r OSGi' or if you have installed remote shell for felix, telnet
> localhost 6666.
>
> Best regards,
> Marotta
>
>
>
>
> --
> View this message in context: http://apache-felix.18485.n6.nabble.com/Felix-as-a-Daemon-tp4835859p5001073.html
> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org