I want to start my workers when I start my development server to test the a new cron job I have in my resque scheduler, so I run this command when starting dev server-
QUEUE=* rake environment resque:work rails s
it has worked for me before and if I'm reading their documentation correctly should still work.
But I'm getting the following error after I interrupt it after it gets hung up-
^Crake aborted!
Don't know how to build task 'rails'
here is what I get after keyboard interrupt and running it with --trace
** Invoke environment (first_time)
** Execute environment
** Invoke resque:work (first_time)
** Invoke resque:preload (first_time)
** Invoke resque:setup (first_time)
** Invoke environment
** Execute resque:setup
** Execute resque:preload
** Invoke resque:setup
** Execute resque:work
^Crake aborted!
Don't know how to build task 'rails'
I don't understand why I would be getting the error and additionally why it previously loaded and worked but not anymore. What am I missing here?
Are you sure that you manage to run this command sometime back successfully
QUEUE=* rake environment resque:work rails s
because the way I know rails s is a list of rails command not a rake task
you can run consecutive rake separating spaces like
QUEUE=* rake environment rake1 rake2 rake3
but you cant run a rake and rails command they way you mention above
what I see from your trace above that rake(resque rake) is running now instead of passing a second rake you specified a rails command to start the server rake is considering that as rake task (which is not true)
I believe you are looking for this
QUEUE=* rake environment resque:work && rails s
But I dont believe that what you have mention would ever work please let me know if something conflict over here
Hope It make sense
This is better:
BACKGROUND=yes QUEUE=* PIDFILE=./tmp/resque.pid bundle exec rake environment resque:work
Then:
rails s
If you need stop resque worker:
kill -QUIT $(cat ./tmp/resque.pid)
Related
I'm trying to test out my Ruby on Rails app. I have redis running, I have a rails server setup and I started a Resque worker in the terminal via the command rake resque:work QUEUE=*, which responds correctly with INFO 2020-01-08 12:10:00 -0500: Starting worker main. When I check the Resque UI in my browser it shows 0 out of 0 workers working. I don't get any error messages in either the terminal or the browser. No jobs are getting picked up, and when I check Resque.workers in the rails console it returns an empty array even while the worker is running in an adjacent tab.
Another test I tried is using --trace as so:
bundle exec rake resque:work --trace
** Invoke resque:work (first_time)
** Invoke resque:preload (first_time)
** Invoke resque:setup (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute resque:setup
** Execute resque:preload
** Invoke resque:setup
** Execute resque:work
set QUEUE env var, e.g. $ QUEUE=critical,high rake resque:work
Which, as shown above, doesn't return anything of notice (at least to me). Anyone know why my workers aren't being acknowledged?
So I ended up fixing this by changing the redis db to use 0 instead of 1
'redis://localhost:6379/0'
Any other number results in the workers not being picked up or acknowledged although I can't say why. If anyone knows I'm still interested in hearing what's going on here even though it's solved.
I've recently updated an old application to from 3.2.13 to 4.2.10. I've got the application running in development mode but any rake or rails commands I try to run just hang/freeze. The terminal window will hang for a second and then nothing, I'm unable to even stop the process with ctrl-c. I've read a lot about running 'spring stop' to fix this but I don't have spring installed on this app.
Running the commands with --trace aren't particularly helpful.
rails generate model Foo --trace gives me nothing and rake db:migrate --trace gives me:
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
before freezing. Any pointers in the right direction would be appreciated.
I have a script/cibuild script, which I run on Semaphore Hosted CI Service), that contains…
time bundle exec rake db:setup db:test:prepare --trace; echo
… to setup the database and check if are there any pending migrations, but for some reason this won’t work not even on my development machine.
Striping down script/cibuild’s contents boils down to this:
export RAILS_ENV=test
export RACK_ENV=test
# options to rake 'spec' task
export SPEC_OPTS='--color --format documentation --backtrace spec'
echo "Installing dependencies..."
time bundle install --deployment; echo
echo "Setting-up database..."
time bundle exec rake db:setup db:test:prepare --trace; echo
echo "Running tests..."
time bundle exec rake spec --trace; echo
Build will eventually fail with the following trace on Semaphore:
Running tests...
** Invoke spec (first_time)
** Invoke test:prepare (first_time)
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:abort_if_pending_migrations
You have 10 pending migrations:
20130418144736 CreateUsers
20130424134725 CreateCollections
20130506124127 AddStaffToUsers
20130513115848 CreateResourceTypes
20130513140804 InstallHstore
20130513141924 CreateResources
20130513144332 AddCredentialDataToUsers
20130523155851 RenameSubscriptionDataInResource
20130531110125 AddProfilePictureToUser
20130722101545 AddEmailIndexToUser
Run `rake db:migrate` to update your database then try again.
Now it seems to me that the problem may not be at db:setup db:test:prepare line, but instead when rake spec is run. I am not sure.
In any case if I run in my development machine…
rake db:drop:all
rake db:setup db:test:prepare
… I will end up with an empty test database (“empty” as in no tables, etc.) whereas…
rake db:drop:all
rake db:setup
rake db:test:prepare
… will create also test database, as expected.
One might think as if I didn’t run rake db:migrate at some point (hence 10 pending migrations), but I am pretty confident that this isn’t the case. Although I don’t have a db/schema.rb file, rails should apply all the migrations to get to the final database schema just fine.
Any ideas, please? Thank you.
Update:
I kind of suspect that the issue might be related to setting RACK_ENV and/or RAILS_ENV environment variables to test. This seems to mess things up a bit.
I'm trying to run a migration on my Rails app, by using rake:db migrate --trace and I get the following output:
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
It then doesn't do anything after this. If I Ctrl + C I get some errors, but I'm not sure I understand them. Is there any way I can step through and debug the migration process so I can see when it hits the problem migration?
its (space between rake and db).
rake db:migrate
try for a overview of rake db tasks:
rake -T db
Try
bundle exec rake db:migrate --trace
I realized the reason this was not firing was it was initializing a sleep command waiting on something that wouldn't be initialized via rake (the app had to be running). So, rake was not the culprit this time!
Ok so i have two rails application on my server and both apps use thinking sphinx and all seems good with one app. when i do
rake ts:start RAILS_ENV=production
Started successfully (pid 9943).
but when i do it on the other app i get
rake ts:start RAILS_ENV=production --trace
** Invoke ts:start (first_time)
** Invoke thinking_sphinx:start (first_time)
** Invoke thinking_sphinx:app_env (first_time)
** Execute thinking_sphinx:app_env
** Invoke environment (first_time)
** Execute environment
Jammit Warning: Asset compression disabled -- Java unavailable.
Jammit Warning: No assets match 'public/stylesheets/public.css'
** Execute thinking_sphinx:start
Failed to start searchd daemon. Check /var/www/projects/log/searchd.log.
Failed to start searchd daemon. Check /var/www/projects/log/searchd.log
** Execute ts:start
they are both using different ports....any idea...also i checked the log file here /var/www/projects/log/searchd.log and its blank ...any idea what to do...i have tried almost everything
rake ts:start starts your sphinx daemon. If you want your apps to share the same search engine, you should only do ts:start once. and both apps should work.