Git Product home page Git Product logo

Comments (12)

gstroup avatar gstroup commented on June 26, 2024

Hi Kevin,

Sorry, I didn't get a chance to look at this yet. The task should just start up the apimocker server... The task will stop, but the server should keep running. I'll take a look at it and get back to you.

Thanks.

-Greg

On Jun 17, 2014, at 7:52 AM, snyoz [email protected] wrote:

How Can I start the task on watch with my node?
Which port I have to choose in my config.json?

When I do: $ grunt apimocker it starts successfully. But after it the task stops.

I would be very thankful for your help.
I followed all your instructions but it doesnt work.

Kind regards,
Kevin


Reply to this email directly or view it on GitHub.

from grunt-apimocker.

snyoz avatar snyoz commented on June 26, 2024

Hi Greg,

thanks for your fast answer. It would be very nice if you take a look.
I have to say that you have done a great work! :)

It would be also very great if you could help me with this question:
gstroup/apimocker#8

Kind regards

from grunt-apimocker.

gstroup avatar gstroup commented on June 26, 2024

Hi,

I added a new sample-project-gruntfile.js to this github project for documentation. I hope this helps you. I used it for testing out the grunt-apimocker task. You can see around line 315, that I run apimocker as part of the 'serve' grunt task, not as part of the 'watch' task. Does this do what you need? The 'watch' task doesn't really make sense for apimocker… since you don't want to start the apimocker server whenever you make a change in your app. Right? If you do want it to run as part of the 'watch' task, can you explain your use case? Thanks.

-Greg


grunt.registerTask('serve', function (target) {
    if (target === 'dist') {
        return grunt.task.run(['build', 'connect:dist:keepalive']);
    }

    grunt.task.run([
        'apimocker',
        'clean:server',
        'concurrent:server',
        'autoprefixer',
        'connect:livereload',
        'watch'
    ]);
});

from grunt-apimocker.

gstroup avatar gstroup commented on June 26, 2024

@snyoz Please let me know if my last comment helped solve your problem, or if you need something else. Thanks.

-Greg

from grunt-apimocker.

kevinoconnor7 avatar kevinoconnor7 commented on June 26, 2024

I can also confirm that the server does not stay up once the task completes. Running apimocker path_to_config shows everything running okay and the server stays up. Using grunt apimocker shows the correct startup to get the server listening but then the task completes and the server is no longer running.

from grunt-apimocker.

snyoz avatar snyoz commented on June 26, 2024

Hi Greg,

it was perfectly for me! Great!
Really good work, thank you!

The only thing I added additionally was:
(maybe it helps @kevinoconnor7 )

// Enable API MOCKER
        apimocker: {
            options: {
              configFile: 'node_modules/grunt-apimocker/node_modules/apimocker/config.json'
            }
        },

and to watch the JSON Mocks:

// Watches files for changes and runs tasks based on the changed files
        watch: {
            apimocker: {
                files: ['node_modules/grunt-apimocker/node_modules/apimocker/mocks/{,*/}*.json']
            },
         },

Kind regards

from grunt-apimocker.

gstroup avatar gstroup commented on June 26, 2024

@kevinoconnor7 Did you get this working yet? Hopefully the comments in this thread were helpful for you. If you still have issues, let me know.

from grunt-apimocker.

themocs avatar themocs commented on June 26, 2024

Hi @gstroup.. im traying to use this grunt no global, but server never starts, tested with this configs but doesn't keep alive. Any solution to this?

Command: grunt apimocker
Output:
Running "apimocker" task
Starting apimocker server
Loading config file: ..../node_modules/grunt-apimocker/node_modules/apimocker/test/test-config.json
Set route: GET first : king.json
Mock server listening on port 7879

Done, without errors.

from grunt-apimocker.

gstroup avatar gstroup commented on June 26, 2024

I think the problem is that the apimocker server will only stay up and running as long as another grunt task keeps the process up and running. If you run apimocker in your grunt 'serve' task, along with a web server like express, then the apimocker server process should remain up and running. Can you try that?

(This is an issue that we need to fix in this grunt-apimocker plugin project, but I haven't had time to work on it. Pull requests welcome!)

from grunt-apimocker.

moro-programmer avatar moro-programmer commented on June 26, 2024

Hi Greg, thank you for your plugin. It seems to me that you can fix it just adding this.async() at the end of the tasks/apimocker.js file

like this

 grunt.log.writeln('Starting apimocker server');    
    var mocker = require('apimocker'),
        mockServer = mocker.createServer().setConfigFile(options.configFile);
        mockServer.stop().start();
    this.async();
 }

But if you do this, all previous configs will be broken. If you want, I can add an optional parameter and send you a pull request.

from grunt-apimocker.

gstroup avatar gstroup commented on June 26, 2024

@moro-programmer, I think you have a good idea. But why would it break all previous configs? Sorry, I have not given much attention to this plugin. If you are able to make a pull request, that would be great! I will get it merged in pretty quickly. Thanks a lot.

from grunt-apimocker.

moro-programmer avatar moro-programmer commented on June 26, 2024

Hi. All previous configs can be broken because the next task waits apimocker. But I have added the wait parameter with default state "false". If you set it true, then the apimocker will not exit. I have sent you the pull request.

from grunt-apimocker.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.