Forum Discussion

VNygaard's avatar
VNygaard
New Contributor
17 years ago

Running the MockService functionality on Linux as a background process

Anyone know how to get the mockservicerunner to run in a background process on linux? (have tried > nohup /progs/soapui-1.7.6/bin/mockservicerunner.sh -p 4950 -m MockSubscriptionService Subscription-Mock-soapui-project.xml &  but it doesn't run, can only run in a terminal session in the foreground, which isn't ideal when using on a remote server) .

7 Replies

  • omatzura's avatar
    omatzura
    Super Contributor
    Hi!

    maybe it's just a typo in your post, but there shouldn't be any spaces between a flag and its value, ie "-p 4950" should be "-p4950"..

    Although I'm pretty sure that isn't the issue here.. could it be some security related issue? what output are you getting in nohup.out?

    regards!

    /Ole
    eviware.com
  • VNygaard's avatar
    VNygaard
    New Contributor
    Hi.. 

    Contents of the nohup... 

    ================================
    =
    = SOAPUI_HOME = /progs/bea/soapui-1.7.6
    =
    ================================
    soapUI 1.7.6 MockService Runner
    Configuring log4j from [jar:file:/progs/bea/soapui-1.7.6/bin/soapui-1.7.6.jar!/soapui-log4j.xml]
    11:25:08,995 WARN  [DefaultSoapUICore] Missing folder [/progs/bea/soapui-1.7.6/ext] for external libraries
    11:25:09,030 INFO  [DefaultSoapUICore] Creating new settings at [/progs/bea/soapui-1.7.6/soapui-settings.xml]
    11:25:11,285 INFO  [WsdlProject] Loaded project from [file:/progs/bea/soapui-1.7.6/MetroSubscription-Mock-soapui-project.xml]
    11:25:11,487 INFO  [SoapUIMockServiceRunner] Running MockService [MockMetroSubscriptionService] in project [MetroSubscription]
    11:25:11,487 INFO  [SoapUIMockServiceRunner] Press any key to terminate
    Progress: 1 - Loading definition from cache
    11:25:11,967 DEBUG [WsdlContext] Loading definition from cache
    11:25:11,984 DEBUG [WsdlLoader] Returning baseInputSource [file:H:\Mine Dokumenter\WSDL\MetroSubscription.wsdl]
    Retrieving document at 'file:H:\Mine Dokumenter\WSDL\MetroSubscription.wsdl'.
    11:25:12,196 DEBUG [WsdlContext] Loaded definition: ok
    11:25:12,223 INFO  [SchemaUtils] Added default schema from file:/progs/bea/soapui-1.7.6/bin/soapui-1.7.6.jar!/xop.xsd with targetNamespace http://www.w3.org/20
    04/08/xop/include
    11:25:12,249 INFO  [SchemaUtils] Added default schema from file:/progs/bea/soapui-1.7.6/bin/soapui-1.7.6.jar!/XMLSchema.xsd with targetNamespace http://www.w3.
    org/2001/XMLSchema
    11:25:12,250 INFO  [SchemaUtils] Added default schema from file:/progs/bea/soapui-1.7.6/bin/soapui-1.7.6.jar!/xml.xsd with targetNamespace http://www.w3.org/XM
    L/1998/namespace
    11:25:12,251 INFO  [SchemaUtils] Added default schema from file:/progs/bea/soapui-1.7.6/bin/soapui-1.7.6.jar!/swaref.xsd with targetNamespace http://ws-i.org/p
    rofiles/basic/1.1/xsd
    11:25:12,252 INFO  [SchemaUtils] Added default schema from file:/progs/bea/soapui-1.7.6/bin/soapui-1.7.6.jar!/xmime200505.xsd with targetNamespace http://www.w
    3.org/2005/05/xmlmime
    11:25:12,252 INFO  [SchemaUtils] Added default schema from file:/progs/bea/soapui-1.7.6/bin/soapui-1.7.6.jar!/xmime200411.xsd with targetNamespace http://www.w
    3.org/2004/11/xmlmime
    11:25:12,253 INFO  [SchemaUtils] Loading schema types from [file:H:\Mine Dokumenter\WSDL\MetroSubscription.wsdl]
    11:25:12,259 INFO  [SchemaUtils] Getting schema file:H:\Mine Dokumenter\WSDL\MetroSubscription.wsdl
    11:25:12,292 INFO  [SchemaUtils] schema for [http://origo.service.metro2.telenor.com] contained [{}] namespaces
    11:25:12,293 INFO  [SchemaUtils] schema for [http://billing.arrangement.origo.service.metro2.telenor.com] contained [{}] namespaces
    11:25:12,295 INFO  [SchemaUtils] schema for [http://subscription.arrangement.origo.service.metro2.telenor.com] contained [{}] namespaces
    11:25:12,295 INFO  [SchemaUtils] schema for [http://status.dto.common.oms.system.metro2.telenor.com] contained [{}] namespaces
    11:25:12,295 INFO  [SchemaUtils] schema for [http://ejb.arrangement.origo.service.metro2.telenor.com] contained [{}] namespaces
    11:25:12,295 INFO  [SchemaUtils] schema for [http://exceptions.soap.commons.metro2.telenor.com] contained [{}] namespaces
    11:25:12,662 INFO  [MockEngine] Started mockService [MockMetroSubscriptionService] on port [4950] at path [/mockMetroSubscriptionService]
    11:25:12,663 INFO  [SoapUIMockServiceRunner] MockService started on port 4950 at path [/mockMetroSubscriptionService]

    [1]+  Stopped                nohup ./mw_start.sh



    //////
    Theres still the processes running  ...

    703957  9690 32003  0 11:25 pts/2    00:00:00 /bin/sh ./mw_start.sh
    703957  9691  9690  0 11:25 pts/2    00:00:00 /bin/sh ./bin/mockservicerunner.sh -p4950 -m MockMetroSubscriptionService MetroSubscription-Mock-soapui-project
    703957  9695  9691  3 11:25 pts/2    00:00:06 java -cp /progs/bea/soapui-1.7.6/bin/soapui-1.7.6.jar:/progs/bea/soapui-1.7.6/lib/activation-1.1.jar:/progs/bea

    ..but it won't respond to any requests..

    It runs fine in foreground, (exists okay when any key pressed),  could it be something to do with the process waiting for a key request; so can*t be submitted to a background process?
  • omatzura's avatar
    omatzura
    Super Contributor
    Hi,

    hmm.. do you mean you need to press a key before it starts working in the foreground?

    regards,

    /Ole
    eviware.com
  • VNygaard's avatar
    VNygaard
    New Contributor
    Hi..

    It's running okay in foreground, but it sits waiting a keystroke to terminate..

    We downloaded the source..  In the SoapUIMockServiceRunner class..

    /**
    * Runs the configured tool for the specified interface.. needs to be refactored to use
    * some kind of registry/factory pattern for tools
    *
    * Param iface
    */

    public void runMockService( WsdlMockService mockService )
    {
    try
    {
    if( path != null )
    mockService.setPath( path );

    if( port != null )
    mockService.setPort( Integer.parseInt( port ));

    mockService.addMockRunListener( new LogListener() );
    MockRunner runner = mockService.start();

    System.in.read();
    runner.stop();
    }
    catch (Exception e)
    {
    SoapUI.logError( e );
    }
    }

    ..is probably preventing it from being ran in the background..
  • omatzura's avatar
    omatzura
    Super Contributor
    ok.. hmm.. but the MockService still starts up as seen in the log.. how could this line stop it from handling requests? Should we add an option to not read but just.. do what..  a Thread.sleep( 1000 ) loop?

    regards!

    /Ole
    eviwarae.com
  • VNygaard's avatar
    VNygaard
    New Contributor
    Hi..

    It would be okay to just let it run.  Then to shutdown it'd be a case of a process kill..  It'd also be nice if it could accept multiple mock Services.  I haven't looked too much into the code yet, but I guess it wouldn't take much of a change to allow it?  Maybe I'll take a look a little later this evening. 

    ..Regards
    ..Vidar
  • omatzura's avatar
    omatzura
    Super Contributor
    Hi Vidar,

    ok, let me know if you make any improvements that we should put in the sources!

    Regarding running multiple MockServices, the idea is currently that this should be done by simply running multiple MockServicerRunners. This has the overhead of multiple processes, which is also an advantage if you need to restart them separately. You could probably pretty easily extend the current commandline to accept a comma-seperated list of ports and mockservices which would start them all..

    Looking a bit into the future we want to create a standalone web-app that can be accessed through a browser and used to start/stop/monitor any number of mock-services.. ie a "MockService Runtime".. which would be really cool.. but a bit down the line for now :-)

    regards!

    /Ole
    eviware.com