Comments (13)
I'll work on this once I get to work!
from grunt-express-server.
I think I figured out (part) of the issue, I am calling express' app.listen
with a callback and printing a custom message on success, this is probably not being caught by the output regexp on grunt-express-server
, because without it, the server starts without automatically stopping (It doesn't return control of the shell though, is it supposed to?). This doesn't solve the issue with the server stop though, I still get a EADDINUSE
and an error that seems to imply it is trying to start the server again.
from grunt-express-server.
Hey @uorbe001, background
is true
by default, so can you help me out with the following:
- Your
express:assets
config block - The
grunt express:assets ...
command that I can use the debug the problem
?
from grunt-express-server.
Here's a project that may help show how I'm using it for now:
I never call :stop
, because the server stops on its own when the task is called again.
You can customize the output
option to match your script, though it defaults to /.+/
currently.
Can you help me out with my previous 2 requests so I can help debug this?
from grunt-express-server.
@ericclemmons Thanks for the help.
Not sure what you mean by the grunt command, the commands I'm running are grunt express:assets
to start the server and grunt express:assets:stop
to stop it. Starting the server with the callback and custom message on listen results in what I got on my original message, but I think this might be a problem with me outputting to the wrong stream or something like that (was simply using console.log, might be that isn't the right thing to use here). Without the listen callback, what I get is the server starting the task but doesn't give me control over the shell, which isn't the behavior I expected (but might be right).
When I stop the server, I always get the EADDINUSE
, am looking into your project to see if I can make the server stop automatically when the task is called too, but I'd rather not leave the server running if possible O:)
My express config block:
express: {
dev: {
options: {
script: 'app/server.js'
}
},
assets: {
options: {
script: 'spec/support/server.js',
background: true
}
}
}
This is the server file just in case you can spot something wrong:
var express = require("express");
var app = express();
app.configure(function () {
app.use(express.static(__dirname + '/static'));
});
module.exports = app.listen(6543);
from grunt-express-server.
Alright, so a couple of things:
background: true
shouldn't be necessary, it's the default. Setting it tofalse
basically says "no matter what the server spits out, keep it running until it exits on its own".- Try adding the option
delay: 1000
and see if that resolves the behavior. - Append a callback to
app.listen
that logs something
module.exports = app.listen(6543, function() {
console.log("Express server listening on port " + app.get('port'));
});
from grunt-express-server.
@ericclemmons I tried adding that callback to the listen (and removed the background from my grunt config), and it doesn't change anything, it still exists the server as soon as it is started. Adding the delay doesn't seem to change anything for me either.
As for the background
option, it doesn't sound like it does what I thought it did, so thanks for the clarification :)
I tried getting your commit 01ed2d3 and I get the same behavior I get with my code, both with the callback and without it. In case it helps, I'm using node 0.10.4 (with nvm).
from grunt-express-server.
At this point, I think you'll have to provide a simple project that I can test and fix it with.
from grunt-express-server.
@ericclemmons I can replicate both problems with:
- git clone https://github.com/ericclemmons/grunt-express-server.git
- cd grunt-express-server
- git checkout 01ed2d3
- npm install
- grunt express:quiet
This causes the terminal to show the server started but doesn't give me shell control back:
Running "express:quiet" (express) task
Starting background Express server
At this point, if I run grunt express:quiet:stop
from another shell, I get the EADINUSE
error.
For the start & stop error, I can repeat steps 1-4 from before and:
- modify test/server-quiet.js to this:
"use strict";
/**
* Test Server
*/
var app = require('./app');
module.exports = app.listen(app.get('port'), function() { console.log('something'); });
- grunt express:quiet
That prints this for me:
Running "express:quiet" (express) task
Starting background Express server
something
Done, without errors.
Stopping Express server
As I said, I'm using node v0.10.4 installed with nvm, in case it helps. I can try to make a sample project, but given that I can replicate it with that same code, I don't see how it would help?
from grunt-express-server.
That's enough for me! Let me see what happens on my end. Thank you!
from grunt-express-server.
- Starting
grunt __anything__
does not know about anything you do in anothergrunt __something__
window. If you want to stop the server, just simply Ctrl-C the grunt process on the original window. - The way grunt works, running
express:quiet:stop
will fall back toexpress:quiet
, starting the server, when there's no pre-existing server running. - Grunt tasks are made to run, complete, and hand control back to grunt. In your last example, you're starting a server, the control gets passed to grunt, there's no remaining tasks to run, so grunt exits, thereby causing express to exit. If you want to run a server, just run
node path/to/server.js
ornpm start
or equivalent. If you want the task to keep the server running until you break via Ctrl-C, setoptions: { background: false; }
, which will run the express server in the foreground and keep control away from grunt until you cancel the process.
The normal use case for this task (and almost every other grunt or Yeoman task) is something like:
$ grunt clean less concat minify express watch
watch
is the task that keeps grunt running and calls express
repeatedly upon changes.
Does that make sense now?
from grunt-express-server.
@ericclemmons That makes sense, thanks for the help and the clarification. I tried running the express tasks on a more 'complex' task as I intended originally, and it works as expected when I add any output on the callback for the app.listen
. If I don't have a callback on the listen, the 'complex' task seems to get stuck as soon as it starts the server though (I get no output after the "Starting background express server"), but this might be an issue with my task.
from grunt-express-server.
Hey, quite a bit late, but have you tried changing the port ? because the error code EADINUSE makes me think of that.
from grunt-express-server.
Related Issues (20)
- using traceur as preprocessor HOT 6
- add restart option HOT 2
- initial server not closed HOT 4
- Fatal error: Cannot read property 'hardStop' of null HOT 8
- Express server crashes unexpectedly, no error log HOT 2
- Settings backround to true doesn't keep the server running HOT 3
- not running correct app; cwd problems HOT 2
- Pass args to non-background process is restricted
- fallback implementation question HOT 6
- THE NEW REPO TO CONTINUE THIS GRUNT TASK
- --debug is deprecated HOT 4
- Can't find the default port of grunt-express-server HOT 1
- is it possible to integrate bunyan's CLI with this? HOT 2
- How to use when console.log outputs to file
- Server is stopped. HOT 1
- Output loses formatting HOT 3
- No page refresh but all else works HOT 3
- Specifying a port is ignored HOT 1
- Error: listen EADDRINUSE HOT 2
- Looking for Contributors / Owners HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grunt-express-server.