Coder Social home page Coder Social logo

Daemonize about filewatcher HOT 4 CLOSED

filewatcher avatar filewatcher commented on June 25, 2024
Daemonize

from filewatcher.

Comments (4)

thomasfl avatar thomasfl commented on June 25, 2024

The --restart option makes filewatcher run the command supplied as a parameter in the background:

    $ filewatcher --restart  "**/*.html" "webserver"

Every time an html file changes, filewatcher will kill the webserver process and start it again in a new process.

So if you want to run filewatcher in the background, you can actually supply filewatcher as a command to filewatcher itself. I haven't tested this, but it may look something like this:

    $ filewatcher --restart  "**/*.html" "$ filewatcher --restart  '**/*.html' 'tail -f some_log_file'"

If you wan't to get some hints on how to run things in the background, please have a look at

https://github.com/thomasfl/filewatcher/blob/master/bin/filewatcher

Processes are run in the background simply by using

  pid = Process.spawn(env, cmd)

I have to admit I am not sure what you are trying to accomplish.

from filewatcher.

AlexWayfer avatar AlexWayfer commented on June 25, 2024

Okay, that's example for my case:

#!/usr/bin/env ruby

def bash(command)
    system "bash -c \"#{command}\""
end

def server(command)
    pumactl = "pumactl #{command} -F config/puma.rb"
    bash pumactl
    return unless %i(start restart).include?(command) && environment == 'development'
    bash 'pkill -f filewatcher'
    bash "filewatcher '**/*.{rb,ru,yml}' '#{pumactl}' > /dev/null &"
end

def monitor_server
    bash "tail -f log/{stdout,stderr} -q"
end

## Runtime
case ARGV[0]
when 'start'
    server :start
when 'stop'
    server :stop
when 'restart'
    server :restart
when 'monitor'
    monitor_server
when 'devel'
    server :restart
    puts 'Waiting for logs...'
    sleep 2
    monitor_server
end

from filewatcher.

AlexWayfer avatar AlexWayfer commented on June 25, 2024

Processes without daemonizing binds to Ruby script, as I think (also with &, or Process.spawn). So… When I press Ctrl+C — it's stop all binded processes too. But… I want to stop tail, not filewatcher. It's must be self-daemonizing, as I think (as puma) for that. But how? Or is there some workarounds?

from filewatcher.

AlexWayfer avatar AlexWayfer commented on June 25, 2024

Maybe that can be some helpful for your gem?

from filewatcher.

Related Issues (20)

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.