question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Gulp as a background task

See original GitHub issue

It would be great to have gulp run as a background task, especially when things like gulp.watch are going on, so that users don’t have to have so many terminal windows open. I’m not sure if this would have to be implemented per gulp plugin, or through Gulp as a whole. It’s just a thought though, and I’m looking to get some ideas on it, if there’s a better way to have a server running and gulp.watch (or a similar process) running concurrently.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
yocontracommented, Aug 29, 2014
1reaction
doowbcommented, Oct 21, 2017

I found that screen is a good tool to use for that. I’m not positive on exactly how it works, but I think it creates a new terminal instance to run the process in.

I’ve been doing something similar to this:

$ screen -dmSL gulp gulp build

This does the following:

  • screen starts a new terminal screen
  • -dm forces a new session that is detached (this allows you to log out of the terminal and back in later to reconnect)
  • -S name the session (this is the first gulp above) I was experimenting without this and wasn’t getting it to work properly.
  • -L this logs the output to screenlog.0. I’m not sure if this can be changed.

You can check to see if any screens are running by doing screen -ls. You can also reattach to a screen by doing screen -r (if there is only one it will attach, otherwise you’ll have to provide a name found from doing screen -ls.

When reattached, you can do Ctrl+c to stop the session. You can also do Ctrl+a,d to detach from the session if you want it to keep running.

I’ve also found that with the command above if you’re not running .watch, the session will close when the task is finished running. This is useful if it’s just a long running task that you want to check up on the progress of through the screenlog.0 file: tail -f screenlog.0

Hope this helps. Also, this can be used for any process that might be long running.

Read more comments on GitHub >

github_iconTop Results From Across the Web

angularjs - Running Gulp in background always - Stack Overflow
We are unzipping it into a folder in server and executing the gulp serve & . The process starts fine, however exits as...
Read more >
I think the answer is that gulp hasn't been designed to run as a ...
I think the answer is that gulp hasn't been designed to run as a background task (don't ask me for specifics though!), whereas...
Read more >
Gulp Tasks - Dan's Cheat Sheets's documentation!
Gulp calls the task function, which returns when it's done. Even if everything your task is doing is synchronous, this is still wrong...
Read more >
How to Use Gulp.js to Automate Your CSS Tasks - SitePoint
In this article, we look at how you can use Gulp.js to automate a range of repetitive CSS development tasks to speed up...
Read more >
Gulp from Scratch: The Default and Watch Tasks - YouTube
Support Me ::https://www.patreon.com/alecadddhttp://www.alecaddd.com/support-me/http://amzn.to/2DsPZUnCheck out Elementor: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found