You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Wunden Tobias <to...@id.ethz.ch> on 2010/09/09 14:54:26 UTC

Running felix on Gentoo

Hello everyone,

I recently tried to install and run Felix 3.0.2 on Gentoo Linux. For this purpose, I created a start script to start and stop Felix depending on the current runlevel (see below). Gentoo's start-stop-daemon usually is a great choice to achieve that goal, but in this case, I am running into the following issues:

When I start Felix using /etc/init.d/felix start, I can see the process as well as the shell's output in the logs. However, as soon as I log out, the felix process is killed immediately (despite the --background option to the start-stop-daemon). In addition, when I start typing in the shell that was used to start Felix, e. g. to do a "ps aux" to list the running processes", every second character hit is not echoed to the shell.

All this indicated a connection to the Felix shell (gogo), and the only way to solve the problem was by removing all gogo bundles from <felix_home>/bundle. After that, the start-stop-daemon behaved as intended and the login shell kept working as expected.

Now I guess my question would be: did I miss anything, i. e. is there a way to start felix using java -jar <felix_home/felix.jar that starts felix in a daemon mode?

Thanks for any hint on this!
Tobias

/etc/conf.d/felix:
============

# felix filesystem layout

FELIX_HOME="/usr/share/felix"
FELIX_CONFDIR="/etc/felix"
FELIX_LOGDIR="/var/log/felix"
FELIX_TEMPDIR="/var/tmp/felix"

# felix configuration

FELIX_BUNDLECACHE="${FELIX_TEMPDIR}/felix-cache"
FELIX_FILEINSTALL_OPTS="-Dfelix.fileinstall.dir=${FELIX_HOME}/load"
PAX_CONFMAN_OPTS="-Dbundles.configuration.location=${FELIX_CONFDIR}"
PAX_LOGGING_OPTS="-Dorg.ops4j.pax.logging.DefaultServiceLog.level=WARN"

# Runtime environment setup

LOG_FILE="${FELIX_LOGDIR}/felix.out"
PID_FILE="/var/run/felix.pid"
FELIX_USER="felix"
FELIX_GROUP="felix"

# JVM configuration

JAVA_HOME="$(java-config --jre-home)"
JVM_MEMORY_OPTS="-Xmx1024m -Xms512m"
JVM_ENCODING_OPTS="-Dfile.encoding=utf-8"


# Java options and commandline

FELIX_OPTS="${FELIX_FILEINSTALL_OPTS} ${PAX_CONFMAN_OPTS} ${PAX_LOGGING_OPTS}"
JVM_OPTS="-server ${JVM_MEMORY_OPTS} ${JVM_ENCODING_OPTS}"

# Final command
RUN_CMD="${JAVA_HOME}/bin/java"
RUN_OPTS="${JVM_OPTS} ${FELIX_OPTS} -jar ${FELIX_HOME}/bin/felix.jar ${FELIX_BUNDLECACHE}"

/etc/init.d/felix:
===========

#!/sbin/runscript
# Distributed under the terms of the GNU General Public License v2

depend() {
       use net
       after logger
}

start() {
       ebegin "Starting Felix"
       mkdir -p "${FELIX_LOGDIR}" "${FELIX_BUNDLECACHE}"
       chown -R ${FELIX_USER}:${FELIX_GROUP} "${FELIX_LOGDIR}" "${FELIX_BUNDLECACHE}"
       if [ ! -d "${FELIX_HOME}" ]; then
           eerror "Felix home directory ${FELIX_HOME} not found"
           return 1
       fi
       start-stop-daemon --start \
           --background \
           --user ${FELIX_USER} \
           --group ${FELIX_GROUP} \
           --chdir ${FELIX_HOME} \
           --make-pidfile \
           --pidfile "${PID_FILE}" \
           --stdout "${LOG_FILE}" \
           --stderr "${LOG_FILE}" \
           --exec "${RUN_CMD}" -- ${RUN_OPTS}
       eend $result
}

stop()  {
       ebegin "Stopping Felix"
       start-stop-daemon --stop \
           --pidfile "${PID_FILE}"
       if [ -e "${PID_FILE}" ]; then
         rm "${PID_FILE}"
       fi
       eend $?
}


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Running felix on Gentoo

Posted by Wunden Tobias <to...@id.ethz.ch>.
Richard,

thanks a lot for taking the time to explain all of that to me. Makes much more sense now.

Happy weekend

Tobias

On 10.09.2010, at 15:21, "Richard S. Hall" <he...@ungoverned.org> wrote:

> On 9/10/10 5:15, Wunden Tobias wrote:
>> The only thing that I don't understand is that if Felix really is only loading bundles, then why should a bundle make assumptions about it's runtime environment (daemon vs. interactive) and shut down the whole framework if these assumptions don't hold. t just seems strange to me, which is likely to mean that I don't understand the design rather than the design being wrong :-)
> 
> The Felix framework is only loading bundles. Actually, the launcher is creating a framework instance and installing/starting any bundles contained in the bundle/ directory. The framework by itself won't load any bundles at all.
> 
> In this particular case, I don't believe that Gogo is shutting down the entire framework, it is just grabbing stdin. In general, you are correct, bundles shouldn't make assumptions about what they are allowed to do; for example, you can't stop bundles from calling System.exit() unless you plan to enable security.
> 
> But the shell bundle is somewhat special in this case. The distribution we provide of the Felix framework is intended to be a developer distribution, which will typically be used in an interactive way by a developer. If you don't want Gogo grabbing stdin, then you should either a) not deploy it or b) configure it not to do so. But from a development perspective, it is doing exactly what we want, since we don't want a headless developer distribution.
> 
> Keep in mind, the situation would be no different for a bundle wanting to display a GUI. In your case, you also wouldn't want this. The OSGi framework is a generic module layer, you can build any type of application with it (interactive or not, server or client, etc.), so everything a bundle does is based on some assumption about how it is going to be used.
> 
> -> richard
> 
>> Again, thanks for your quick (and patient) help!
>> 
>> Tobias
>> ---------------------------------------------------------------------
>> 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
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Running felix on Gentoo

Posted by "Richard S. Hall" <he...@ungoverned.org>.
  On 9/10/10 5:15, Wunden Tobias wrote:
> The only thing that I don't understand is that if Felix really is only loading bundles, then why should a bundle make assumptions about it's runtime environment (daemon vs. interactive) and shut down the whole framework if these assumptions don't hold. t just seems strange to me, which is likely to mean that I don't understand the design rather than the design being wrong :-)

The Felix framework is only loading bundles. Actually, the launcher is 
creating a framework instance and installing/starting any bundles 
contained in the bundle/ directory. The framework by itself won't load 
any bundles at all.

In this particular case, I don't believe that Gogo is shutting down the 
entire framework, it is just grabbing stdin. In general, you are 
correct, bundles shouldn't make assumptions about what they are allowed 
to do; for example, you can't stop bundles from calling System.exit() 
unless you plan to enable security.

But the shell bundle is somewhat special in this case. The distribution 
we provide of the Felix framework is intended to be a developer 
distribution, which will typically be used in an interactive way by a 
developer. If you don't want Gogo grabbing stdin, then you should either 
a) not deploy it or b) configure it not to do so. But from a development 
perspective, it is doing exactly what we want, since we don't want a 
headless developer distribution.

Keep in mind, the situation would be no different for a bundle wanting 
to display a GUI. In your case, you also wouldn't want this. The OSGi 
framework is a generic module layer, you can build any type of 
application with it (interactive or not, server or client, etc.), so 
everything a bundle does is based on some assumption about how it is 
going to be used.

-> richard

> Again, thanks for your quick (and patient) help!
>
> Tobias
> ---------------------------------------------------------------------
> 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


Re: Running felix on Gentoo

Posted by Wunden Tobias <to...@id.ethz.ch>.
Hi Richard,

> You can add system properties to the conf/system.properties file...any properties in this file will be set as system properties. In the future, you should be able to add them to conf/config.properties, but currently there is a bug/limitation in Gogo and it only looks in system properties for its configuration properties.

Good to know, thank you!

> The Felix framework knows nothing about the shell. This is a Gogo issue. The framework just loads the bundles you tell it to.
> 
> Still, the Gogo shell has to either come up interactive or not...we have to choose one. Either way, you'll need to set a property to get the opposite of the default behavior.
> 
> And just because some daemon system is picky about parsing doesn't necessarily mean we are to blame. :-)

Hey, I am not blaming you for anything! Felix with the various subprojects is a great piece of software and there is really nothing to blame. 

The only thing that I don't understand is that if Felix really is only loading bundles, then why should a bundle make assumptions about it's runtime environment (daemon vs. interactive) and shut down the whole framework if these assumptions don't hold. t just seems strange to me, which is likely to mean that I don't understand the design rather than the design being wrong :-)

Again, thanks for your quick (and patient) help!

Tobias
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Running felix on Gentoo

Posted by "Richard S. Hall" <he...@ungoverned.org>.
  On 9/9/10 8:00 PM, Wunden Tobias wrote:
> Hi Richard,
>
> thanks for that quick and generally helpful answer, this was exactly what I was looking for! However, implementing your idea, I ran into various issues, all of them being related to the start-stop-daemon being picky about the correct quoting.
>
> I first tried to add what you had suggested to my other RUN_OPTS, but then the java vm would not be created and complained about an unknown option "-c". After trying every possible way of quoting the arguments to -Dgosh.args, and finding that others on the web had dealt with that problem as well withouth success, I ended up doing this:
>
> --exec "${RUN_CMD}" -- -Dgosh.args="--noshutdown -c noop=true" ${RUN_OPTS}
>
> which is not nice but is working. Just sending this out so that others can save the hour of investigative work that I just spent :-)
>
> Maybe there is another way of passing in arguments to the shell at startup time?

You can add system properties to the conf/system.properties file...any 
properties in this file will be set as system properties. In the future, 
you should be able to add them to conf/config.properties, but currently 
there is a bug/limitation in Gogo and it only looks in system properties 
for its configuration properties.

> At least it might be worthwhile considering *one* option that will tell Felix and the rest of the gang to work in non-interactive mode rather than trying to trick the gogo shell into it. But I will frankly admit that I don't fully understand the architectural decisions made around the shell, so please forgive me if I am asking for obvious nonsense.

The Felix framework knows nothing about the shell. This is a Gogo issue. 
The framework just loads the bundles you tell it to.

Still, the Gogo shell has to either come up interactive or not...we have 
to choose one. Either way, you'll need to set a property to get the 
opposite of the default behavior.

And just because some daemon system is picky about parsing doesn't 
necessarily mean we are to blame. :-)

-> richard

> Again, thanks for your help!
>
> Tobias
>
> On 09.09.2010, at 15:51, Richard S. Hall wrote:
>
>> It seems like the Gogo interactive shell is causing you difficulties. When the Gogo shell starts up, it expects to either 1) start an interactive session or 2) execute a command. You can avoid (1) by doing (2) and telling it to not shutdown the framework, something like this:
>>
>>     java -Dgosh.args='--noshutdown -c noop=true' -jar bin/felix.jar
>>
>> Then if you also install the newly released Remote Shell bundle, you can telnet into the running framework. In fact, Gogo has a built-in telnet command, so I think you could just directly start it like this without the Remote Shell bundle:
>>
>>     java -Dgosh.args='-sc telnetd -p1234 start' -jar bin/felix.jar
>>
>> Either approach will start Gogo without an interactive session and the ability to telnet into it.
> ---------------------------------------------------------------------
> 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


Re: Running felix on Gentoo

Posted by Wunden Tobias <to...@id.ethz.ch>.
Hi Richard,

thanks for that quick and generally helpful answer, this was exactly what I was looking for! However, implementing your idea, I ran into various issues, all of them being related to the start-stop-daemon being picky about the correct quoting.

I first tried to add what you had suggested to my other RUN_OPTS, but then the java vm would not be created and complained about an unknown option "-c". After trying every possible way of quoting the arguments to -Dgosh.args, and finding that others on the web had dealt with that problem as well withouth success, I ended up doing this:

--exec "${RUN_CMD}" -- -Dgosh.args="--noshutdown -c noop=true" ${RUN_OPTS}

which is not nice but is working. Just sending this out so that others can save the hour of investigative work that I just spent :-)

Maybe there is another way of passing in arguments to the shell at startup time? At least it might be worthwhile considering *one* option that will tell Felix and the rest of the gang to work in non-interactive mode rather than trying to trick the gogo shell into it. But I will frankly admit that I don't fully understand the architectural decisions made around the shell, so please forgive me if I am asking for obvious nonsense.

Again, thanks for your help!

Tobias

On 09.09.2010, at 15:51, Richard S. Hall wrote:

> It seems like the Gogo interactive shell is causing you difficulties. When the Gogo shell starts up, it expects to either 1) start an interactive session or 2) execute a command. You can avoid (1) by doing (2) and telling it to not shutdown the framework, something like this:
> 
>    java -Dgosh.args='--noshutdown -c noop=true' -jar bin/felix.jar
> 
> Then if you also install the newly released Remote Shell bundle, you can telnet into the running framework. In fact, Gogo has a built-in telnet command, so I think you could just directly start it like this without the Remote Shell bundle:
> 
>    java -Dgosh.args='-sc telnetd -p1234 start' -jar bin/felix.jar
> 
> Either approach will start Gogo without an interactive session and the ability to telnet into it.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Running felix on Gentoo

Posted by "Richard S. Hall" <he...@ungoverned.org>.

On 9/9/10 8:54, Wunden Tobias wrote:
> Hello everyone,
>
> I recently tried to install and run Felix 3.0.2 on Gentoo Linux. For this purpose, I created a start script to start and stop Felix depending on the current runlevel (see below). Gentoo's start-stop-daemon usually is a great choice to achieve that goal, but in this case, I am running into the following issues:
>
> When I start Felix using /etc/init.d/felix start, I can see the process as well as the shell's output in the logs. However, as soon as I log out, the felix process is killed immediately (despite the --background option to the start-stop-daemon). In addition, when I start typing in the shell that was used to start Felix, e. g. to do a "ps aux" to list the running processes", every second character hit is not echoed to the shell.
>
> All this indicated a connection to the Felix shell (gogo), and the only way to solve the problem was by removing all gogo bundles from<felix_home>/bundle. After that, the start-stop-daemon behaved as intended and the login shell kept working as expected.

It seems like the Gogo interactive shell is causing you difficulties. 
When the Gogo shell starts up, it expects to either 1) start an 
interactive session or 2) execute a command. You can avoid (1) by doing 
(2) and telling it to not shutdown the framework, something like this:

     java -Dgosh.args='--noshutdown -c noop=true' -jar bin/felix.jar

Then if you also install the newly released Remote Shell bundle, you can 
telnet into the running framework. In fact, Gogo has a built-in telnet 
command, so I think you could just directly start it like this without 
the Remote Shell bundle:

     java -Dgosh.args='-sc telnetd -p1234 start' -jar bin/felix.jar

Either approach will start Gogo without an interactive session and the 
ability to telnet into it.

-> richard

> Now I guess my question would be: did I miss anything, i. e. is there a way to start felix using java -jar<felix_home/felix.jar that starts felix in a daemon mode?
>
> Thanks for any hint on this!
> Tobias
>
> /etc/conf.d/felix:
> ============
>
> # felix filesystem layout
>
> FELIX_HOME="/usr/share/felix"
> FELIX_CONFDIR="/etc/felix"
> FELIX_LOGDIR="/var/log/felix"
> FELIX_TEMPDIR="/var/tmp/felix"
>
> # felix configuration
>
> FELIX_BUNDLECACHE="${FELIX_TEMPDIR}/felix-cache"
> FELIX_FILEINSTALL_OPTS="-Dfelix.fileinstall.dir=${FELIX_HOME}/load"
> PAX_CONFMAN_OPTS="-Dbundles.configuration.location=${FELIX_CONFDIR}"
> PAX_LOGGING_OPTS="-Dorg.ops4j.pax.logging.DefaultServiceLog.level=WARN"
>
> # Runtime environment setup
>
> LOG_FILE="${FELIX_LOGDIR}/felix.out"
> PID_FILE="/var/run/felix.pid"
> FELIX_USER="felix"
> FELIX_GROUP="felix"
>
> # JVM configuration
>
> JAVA_HOME="$(java-config --jre-home)"
> JVM_MEMORY_OPTS="-Xmx1024m -Xms512m"
> JVM_ENCODING_OPTS="-Dfile.encoding=utf-8"
>
>
> # Java options and commandline
>
> FELIX_OPTS="${FELIX_FILEINSTALL_OPTS} ${PAX_CONFMAN_OPTS} ${PAX_LOGGING_OPTS}"
> JVM_OPTS="-server ${JVM_MEMORY_OPTS} ${JVM_ENCODING_OPTS}"
>
> # Final command
> RUN_CMD="${JAVA_HOME}/bin/java"
> RUN_OPTS="${JVM_OPTS} ${FELIX_OPTS} -jar ${FELIX_HOME}/bin/felix.jar ${FELIX_BUNDLECACHE}"
>
> /etc/init.d/felix:
> ===========
>
> #!/sbin/runscript
> # Distributed under the terms of the GNU General Public License v2
>
> depend() {
>         use net
>         after logger
> }
>
> start() {
>         ebegin "Starting Felix"
>         mkdir -p "${FELIX_LOGDIR}" "${FELIX_BUNDLECACHE}"
>         chown -R ${FELIX_USER}:${FELIX_GROUP} "${FELIX_LOGDIR}" "${FELIX_BUNDLECACHE}"
>         if [ ! -d "${FELIX_HOME}" ]; then
>             eerror "Felix home directory ${FELIX_HOME} not found"
>             return 1
>         fi
>         start-stop-daemon --start \
>             --background \
>             --user ${FELIX_USER} \
>             --group ${FELIX_GROUP} \
>             --chdir ${FELIX_HOME} \
>             --make-pidfile \
>             --pidfile "${PID_FILE}" \
>             --stdout "${LOG_FILE}" \
>             --stderr "${LOG_FILE}" \
>             --exec "${RUN_CMD}" -- ${RUN_OPTS}
>         eend $result
> }
>
> stop()  {
>         ebegin "Stopping Felix"
>         start-stop-daemon --stop \
>             --pidfile "${PID_FILE}"
>         if [ -e "${PID_FILE}" ]; then
>           rm "${PID_FILE}"
>         fi
>         eend $?
> }
>
>
> ---------------------------------------------------------------------
> 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