Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running from procfile w/ API - nothing happens #23

Closed
haf opened this issue May 8, 2015 · 4 comments
Closed

Running from procfile w/ API - nothing happens #23

haf opened this issue May 8, 2015 · 4 comments

Comments

@haf
Copy link

haf commented May 8, 2015

I have a procfile:

---
statics: ./tools/watch_static.rb

And the file:

#!/usr/bin/env ruby

require 'set'
require 'filewatcher'
require 'fileutils'

puts 'starting...'
FileWatcher.new(['src/example.com/css/*', 'src/example.com/*'], true).watch do |file_path, evt|
  if File.directory? file_path
    puts "dir: #{file_path}"
  else
    rel  = file_path.gsub 'src/example.com', ''
    targ = File.join('build/example.com', rel)
    puts "copying #{file_path} to #{targ}"
    begin
      FileUtils.cp file_path, targ
    rescue => e
      puts e
    end
  end
end

And a Gemfile:

source 'https://rubygems.org'

group :dev do
  gem 'foreman'
  gem 'filewatcher'
end

gem 'albacore', '~> 2'

This is the output:

✗ bundle exec foreman start
10:18:18 statics.1 | started with pid 3232

(nothing at the end, that is)

If I start it manually:

➜  example.com git:(feature/app-design) ✗ ./tools/watch_static.rb
starting...
Watching:
src/example.com/css/app.css
src/example.com/css/grid.css
src/example.com/css/main.css
src/example.com/css/normalize.css
src/example.com/css/splash.css
src/example.com/api
src/example.com/app.html
src/example.com/css
src/example.com/fonts
src/example.com/img
src/example.com/index.html
src/example.com/js
src/example.com/node_modules
src/example.com/package.json
src/example.com/README.md
src/example.com/webpack.config.js

With appropriate output if I change a file...

I've tried running foreman with bundler. Foreman without bundler. Both act the same. From within foreman I've tried statics: sh -c './tools/watch_static.rb', bundle exec ruby tools/watch_static.rb and any other combo I can think of. If I print PATH from before the running of the file on the 'statics' row, it prints a valid RBENV-based path which has FileWatcher in its downloaded set of gems. Any other program I run with Procfile works.

I'm on OS X, ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0], and this lockfile:

GEM
  remote: https://rubygems.org/
  specs:
    albacore (2.3.22)
      map (~> 6.5)
      nokogiri (~> 1.5)
      rake (~> 10)
      semver2 (~> 3.4)
    filewatcher (0.5.0)
      trollop (~> 2.0)
    foreman (0.78.0)
      thor (~> 0.19.1)
    map (6.5.5)
    mini_portile (0.6.2)
    nokogiri (1.6.6.2)
      mini_portile (~> 0.6.0)
    rake (10.4.2)
    semver2 (3.4.2)
    thor (0.19.1)
    trollop (2.1.2)

So I'm running out of ideas now. Do you have any pointers?

@thomasfl
Copy link
Collaborator

thomasfl commented May 9, 2015

Hi, I haven''t had the time to try this out myself. But have you considered downgrading filewatcher til version 0.4? The latest version contains some stuff from a pull request, that I haven't tested fully.

@haf
Copy link
Author

haf commented May 9, 2015

Yes, I have. I upgraded just before filing this issue to ensure it wasn't a version problem.

@thomasfl
Copy link
Collaborator

This answer is a bit late, but I know what your problem is. Your watcher script works just fine, it just don't outputs to stdout, so you just don't see any output in your console.

If you add this line to the top of you watcher script, you should see some output in your console:

$stdout.sync = true

@haf
Copy link
Author

haf commented May 15, 2015

@thomasfl thank you! I didn't know about that flag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants