Found the reason

The path used does not correspond to the location where karaf runs on the
cloud machine :

Exception in thread "main" java.io.FileNotFoundException:
/var/lib/stickshift/b8f9c391e35a4ab3b376e66929e7f2f6/app-root/runtime/fabric/data/port
(No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:97)
at org.apache.karaf.main.Stop.main(Stop.java:64)

Is =
 
/var/lib/stickshift/b8f9c391e35a4ab3b376e66929e7f2f6/app-root/runtime/fabric/data/port
and should be
/var/lib/stickshift/b8f9c391e35a4ab3b376e66929e7f2f6/fabric/runtime/fabric/data/port

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
>
>
>


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

Reply via email to