After verification, it appears that karaf.base and karaf.home are defined
correctly and both point to this location
:/var/lib/stickshift/b8f9c391e35a4ab3b376e66929e7f2f6/app-root/runtime/fabric

like also karaf.data
: 
-Dkaraf.data=/var/lib/stickshift/b8f9c391e35a4ab3b376e66929e7f2f6/fabric/runtime/fabric/data

The account has the permissions required to create the file in the data
directory

[fabric-fuse.rhcloud.com bin]\> ls -la
/var/lib/stickshift/b8f9c391e35a4ab3b376e66929e7f2f6/app-root/runtime/fabric/
total 136
drwxr-xr-x. 11 b8f9c391e35a4ab3b376e66929e7f2f6
b8f9c391e35a4ab3b376e66929e7f2f6  4096 Aug 24 13:05 .
drwxr-x---.  5 b8f9c391e35a4ab3b376e66929e7f2f6
b8f9c391e35a4ab3b376e66929e7f2f6  4096 Aug 24 13:05 ..
-rw-r--r--.  1 b8f9c391e35a4ab3b376e66929e7f2f6
b8f9c391e35a4ab3b376e66929e7f2f6  6148 Aug 24 13:05 .DS_Store
drwxr-xr-x.  2 b8f9c391e35a4ab3b376e66929e7f2f6
b8f9c391e35a4ab3b376e66929e7f2f6  4096 Aug 24 13:03 bin
drwxr-xr-x.  6 b8f9c391e35a4ab3b376e66929e7f2f6
b8f9c391e35a4ab3b376e66929e7f2f6  4096 Aug 24 13:03 data

Log are well created like also tmp file and karaf.out

[fabric-fuse.rhcloud.com bin]\> ls -la
/var/lib/stickshift/b8f9c391e35a4ab3b376e66929e7f2f6/app-root/runtime/fabric/data
total 40
drwxr-xr-x.   6 b8f9c391e35a4ab3b376e66929e7f2f6
b8f9c391e35a4ab3b376e66929e7f2f6  4096 Aug 24 13:03 .
drwxr-xr-x.  11 b8f9c391e35a4ab3b376e66929e7f2f6
b8f9c391e35a4ab3b376e66929e7f2f6  4096 Aug 24 13:05 ..
drwxr-xr-x. 110 b8f9c391e35a4ab3b376e66929e7f2f6
b8f9c391e35a4ab3b376e66929e7f2f6  4096 Aug 24 13:05 cache
drwxr-xr-x.   2 b8f9c391e35a4ab3b376e66929e7f2f6
b8f9c391e35a4ab3b376e66929e7f2f6  4096 Aug 24 13:03 generated-bundles
-rw-r--r--.   1 b8f9c391e35a4ab3b376e66929e7f2f6
b8f9c391e35a4ab3b376e66929e7f2f6 14020 Aug 27 04:45 karaf.out
drwxr-xr-x.   2 b8f9c391e35a4ab3b376e66929e7f2f6
b8f9c391e35a4ab3b376e66929e7f2f6  4096 Aug 24 13:03 log
drwxr-xr-x.   4 b8f9c391e35a4ab3b376e66929e7f2f6
b8f9c391e35a4ab3b376e66929e7f2f6  4096 Aug 27 04:46 tmp
[fabric-fuse.rhcloud.com bin]\> ls -la
/var/lib/stickshift/b8f9c391e35a4ab3b376e66929e7f2f6/app-root/runtime/fabric/data/log/
total 76
drwxr-xr-x. 2 b8f9c391e35a4ab3b376e66929e7f2f6
b8f9c391e35a4ab3b376e66929e7f2f6  4096 Aug 24 13:03 .
drwxr-xr-x. 6 b8f9c391e35a4ab3b376e66929e7f2f6
b8f9c391e35a4ab3b376e66929e7f2f6  4096 Aug 24 13:03 ..
-rw-r--r--. 1 b8f9c391e35a4ab3b376e66929e7f2f6
b8f9c391e35a4ab3b376e66929e7f2f6 63222 Aug 27 05:01 karaf.log

Remarks :

- Version used here is karaf 2.2.5 but code is the same compared to trunk
of 2.2.3 -->
https://github.com/apache/karaf/blob/karaf-2.2.5/main/src/main/java/org/apache/karaf/main/Main.java#L1333
- I can create manually the port file but of course the port number added
will be 0.



On Mon, Aug 27, 2012 at 10:46 AM, Guillaume Nodet <[email protected]> wrote:

> The port file is written with the following code:
>
>
> https://github.com/apache/karaf/blob/karaf-2.3.x/main/src/main/java/org/apache/karaf/main/Main.java#L1401
>
> It uses the karaf.shutdown.port.file property which is defined in
> etc/config.properties and defaults to ${karaf.data}/port
> The code is quite simple, so not sure what could go wrong beyond the above
> property not being correctly defined maybe.
>
> On Mon, Aug 27, 2012 at 10:25 AM, Charles Moulliard <[email protected]
> >wrote:
>
> > FYI. In the data directory of the fabric/karaf instance running on
> > openshift, the port file is not created
> >
> > [fabric-fuse.rhcloud.com ~]\> ls
> >
> >
> /var/lib/stickshift/b8f9c391e35a4ab3b376e66929e7f2f6/fabric/runtime/fabric/data/
> > cache/             generated-bundles/ karaf.out          log/
> > tmp/
> >
> > On Mon, Aug 27, 2012 at 10:15 AM, Charles Moulliard <[email protected]
> > >wrote:
> >
> > > In my case, the issue is related to the port file not created by Karaf
> > > when the method setupShutdown is called (
> > >
> >
> https://github.com/apache/karaf/blob/trunk/main/src/main/java/org/apache/karaf/main/InstanceHelper.java
> > )
> > > and not to the pidFile.
> > >
> > >
> > > On Mon, Aug 27, 2012 at 9:45 AM, Guillaume Nodet <[email protected]>
> > wrote:
> > >
> > >> The related code is in
> > >>
> > >>
> > >>
> >
> https://github.com/apache/karaf/blob/trunk/instance/core/src/main/java/org/apache/karaf/jpm/impl/ProcessImpl.java
> > >>
> > >> Could you try maybe deleting the file just after having created it
> using
> > >> createTempFile ?
> > >> The scripts that actually launch the process should create the file
> > >> themselves, but maybe the file is locked by the JVM ...
> > >>
> > >> On Mon, Aug 27, 2012 at 8:54 AM, Charles Moulliard <[email protected]>
> > >> wrote:
> > >>
> > >> > Thx for the clarification
> > >> >
> > >> > Could it be possible that for some reasons (JDK =
> > >> > 7, AccessRights/Permissions, ...), the process to create the port
> file
> > >> > fails on a machine but Karaf is well started ? I ask you this
> question
> > >> as I
> > >> > get an error message (port file not found) when Karaf shutdown on
> > >> openshift
> > >> > cloud machine.
> > >> >
> > >> > On Fri, Aug 24, 2012 at 3:05 PM, Guillaume Nodet <[email protected]>
> > >> wrote:
> > >> >
> > >> > > Both are used in a two step shutdown iirc.
> > >> > > When using bin/stop or when stopping a child instance, we first
> ask
> > >> for
> > >> > the
> > >> > > instance to shutdown cleanly, and if it does not work, the process
> > is
> > >> > > killed using its pid.
> > >> > >
> > >> > > On Fri, Aug 24, 2012 at 1:41 PM, Charles Moulliard <
> > [email protected]>
> > >> > > wrote:
> > >> > >
> > >> > > > Hi,
> > >> > > >
> > >> > > > I'm really curious to discover that we have 2 files doing the
> same
> > >> job
> > >> > (I
> > >> > > > think so) a port file (created in data directory) and a pid file
> > >> (that
> > >> > I
> > >> > > > cannot find in data directory)
> > >> > > >
> > >> > > >         this.pidFile =
> props.getProperty(KARAF_SHUTDOWN_PID_FILE);
> > >> > > >         this.portFile =
> > props.getProperty(KARAF_SHUTDOWN_PORT_FILE);
> > >> > > >
> > >> > > > 1) For PidFile --> org.apache.karaf.main.InstanceHelper
> > >> > > >
> > >> > > >     private static void writePid(String pidFile) {
> > >> > > >         try {
> > >> > > >             if (pidFile != null) {
> > >> > > >             ....
> > >> > > >                 if (matcher.matches()) {
> > >> > > >                     int pid =
> Integer.parseInt(matcher.group(1));
> > >> > > >                     Writer w = new OutputStreamWriter(new
> > >> > > > FileOutputStream(pidFile));
> > >> > > >                     w.write(Integer.toString(pid));
> > >> > > >                     w.close();
> > >> > > >             ...
> > >> > > >     }
> > >> > > >
> > >> > > > Most probably we never create it in this part of the code
> > >> > > >
> > >> > > > 2) Port File --> org.apache.karaf.main.InstanceHelper
> > >> > > >
> > >> > > >     static void setupShutdown(ConfigProperties config, Framework
> > >> > > framework)
> > >> > > > {
> > >> > > >         writePid(config.pidFile);
> > >> > > >         try {
> > >> > > >             int port = config.shutdownPort;
> > >> > > >             String host = config.shutdownHost;
> > >> > > >             String portFile = config.portFile;
> > >> > > >             final String shutdown = config.shutdownCommand;
> > >> > > >             if (port >= 0) {
> > >> > > >                 ServerSocket shutdownSocket = new
> > >> ServerSocket(port, 1,
> > >> > > > InetAddress.getByName(host));
> > >> > > >                 if (port == 0) {
> > >> > > >                     port = shutdownSocket.getLocalPort();
> > >> > > >                 }
> > >> > > >                 if (portFile != null) {
> > >> > > >                     Writer w = new OutputStreamWriter(new
> > >> > > > FileOutputStream(portFile));
> > >> > > >                     w.write(Integer.toString(port));
> > >> > > >                     w.close();
> > >> > > >                 }
> > >> > > >                 Thread thread = new
> ShutdownSocketThread(shutdown,
> > >> > > > shutdownSocket, framework);
> > >> > > >                 thread.setDaemon(true);
> > >> > > >                 thread.start();
> > >> > > >             }
> > >> > > >         } catch (Exception e) {
> > >> > > >             e.printStackTrace();
> > >> > > >         }
> > >> > > >     }
> > >> > > >
> > >> > > > Questions :
> > >> > > > - Do we still need the pid file ? If no can we clean the code ?
> > >> > > > - Could it be possible that for some reasons (JDK = 7,
> > >> > > > AccessRights/Permissions), the process to create the port file
> > fails
> > >> > on a
> > >> > > > machine ? I ask you this question as I get this messsage when I
> > >> tried
> > >> > to
> > >> > > > shutdown karaf on acloud machine
> > >> > > >
> > >> > > > remote: Stopping application...
> > >> > > > remote: Exception in thread "main"
> > java.lang.NumberFormatException:
> > >> > null
> > >> > > > remote: at java.lang.Integer.parseInt(Integer.java:454)
> > >> > > > remote: at java.lang.Integer.parseInt(Integer.java:527)
> > >> > > > remote: at org.apache.karaf.main.Stop.main(Stop.java:66)
> > >> > > > remote: Done
> > >> > > >
> > >> > > >
> > >> > > > Regards,
> > >> > > >
> > >> > > > --
> > >> > > > Charles Moulliard
> > >> > > > Apache Committer / Sr. Pr. Consultant at FuseSource.com
> > >> > > > Twitter : @cmoulliard
> > >> > > > Blog : http://cmoulliard.blogspot.com
> > >> > > >
> > >> > >
> > >> > >
> > >> > >
> > >> > > --
> > >> > > ------------------------
> > >> > > Guillaume Nodet
> > >> > > ------------------------
> > >> > > Blog: http://gnodet.blogspot.com/
> > >> > > ------------------------
> > >> > > FuseSource, Integration everywhere
> > >> > > http://fusesource.com
> > >> > >
> > >> >
> > >> >
> > >> >
> > >> > --
> > >> > Charles Moulliard
> > >> > Apache Committer / Sr. Pr. Consultant at FuseSource.com
> > >> > Twitter : @cmoulliard
> > >> > Blog : http://cmoulliard.blogspot.com
> > >> >
> > >>
> > >>
> > >>
> > >> --
> > >> ------------------------
> > >> Guillaume Nodet
> > >> ------------------------
> > >> Blog: http://gnodet.blogspot.com/
> > >> ------------------------
> > >> FuseSource, Integration everywhere
> > >> http://fusesource.com
> > >>
> > >
> > >
> > >
> > > --
> > > Charles Moulliard
> > > Apache Committer / Sr. Pr. Consultant at FuseSource.com
> > > Twitter : @cmoulliard
> > > Blog : http://cmoulliard.blogspot.com
> > >
> > >
> > >
> >
> >
> > --
> > Charles Moulliard
> > Apache Committer / Sr. Pr. Consultant at FuseSource.com
> > Twitter : @cmoulliard
> > Blog : http://cmoulliard.blogspot.com
> >
>
>
>
> --
> ------------------------
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> ------------------------
> FuseSource, Integration everywhere
> http://fusesource.com
>



-- 
Charles Moulliard
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Twitter : @cmoulliard
Blog : http://cmoulliard.blogspot.com

Reply via email to