Re: [Rails] Rake tasks
Robert, I can't tell you all the ins and outs of your script but what you're seeing here is that rake is looking at the V thinking it is another rake task you want to run (that's why the first one succeeds and then gives you the error) You probably want something like V=true or V=1 or something like that. -Jason On Nov 19, 2014, at 5:11 PM, Robert Fitzpatrick rob...@webtent.org wrote: Robert Fitzpatrick wrote: Maybe I missed something earlier in the discussion, but can't you just edit it to: @verbose = true if arg == 'V' Yes, I guess so, and then uncomment all the places in the code where he has #puts something if @verbose I'll give it a try, still trying to figure out how to run the task. I put the app in development environment with the Apache directive and this is all the deprecated info I mentioned and other output when trying to bundle exec, I get Don't know how to build task 'utils:archives'. Is this how I should be trying to run the task? Never mind my last post, I looked up the command used in cron and made an adjustment to the DIR for my local box and got the expected response. bundle exec rake utils:process_archives V DIR=/tmp I updated the verbose line to recognize the 'V' argument as suggested and it does output the conditional puts lines, but I do get the following at the end rake aborted! Don't know how to build task 'V' The task does appear to complete successfully, with comments if I specify 'V' and without if not, as expected. Is this normal or should I be applying the argument differently? Jason Fleetwood-Boldt t...@datatravels.com http://www.jasonfleetwoodboldt.com/writing All material © Jason Fleetwood-Boldt 2014. Public conversations may be turned into blog posts (original poster information will be made anonymous). Email ja...@datatravels.com with questions/concerns about this. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/93D2A183-E060-4BB5-9CAE-93DCAB47C310%40datatravels.com. For more options, visit https://groups.google.com/d/optout.
Re: [Rails] Rake tasks
Jason Fleetwood-Boldt wrote: Without seeing the task I can't tell you the answer to that. And the fact that it runs on a cron schedule means that you probably have something like a worker in the background doing that. Normally you run rake some_task X=abc Y=xyz I see this piece of code at the start of the task assuming an argument could be used to get the verbose response @verbose = false ARGV.each do |arg| puts arg: #{arg} @verbose = false # if arg == 'V' end Then the code uses '#puts something if @verbose' throughout. Like I said, I'm new to ruby, but have used Perl and PHP and other languages before, I hope is what is throwing me off is the # are not comments? This almost looks like @verbose would always be false. What is this piece of code looking for as an argument? I apologize for trying to get a crash course in ruby here, gonna have to get up to speed soon as this app that was left to me to try and maintain/support. I am reading through the following tutorial to get up to speed as quickly as I can, any other pointers extremely helpful... https://www.railstutorial.org/book But note that you probably want to prefix the rake task in development with bundle exec to get it to run with the right gemset. I downloaded a copy of the app and setup locally on a development server. The production app is running on nginx web server and have the copy running on Apache locally. I saw the following directive available in the nginx conf to enable development, copied to Apache and this is how I am running dev mode... RailsEnv development Then I can run bundle exec rake utils:process_archives? As I posted earlier, there is a script/process_archives.sh file that I thought at first runs the rake task since I see results of the task in the cron log... rake utils:process_archives DIR=/var/www/virtual//htdocs//tmp RAILS_ENV=production But that DIR does not exist on the server, so I'm questioning if this shell script is being used at all. I found further the task in config/schedule.rb... command %{#{cmd_root} cd /var/www/vhosts/wmnf/current bundle exec rake utils:process_archives DIR=/var/www/vhosts//shared/tmp RAILS_ENV=production} Those dirs do exist and I also found in the crontabs... root@app01:~/www# cat /var/spool/cron/crontabs/appuser |grep process 31 * * * * /bin/bash -l -c 'PATH=/opt/ree/bin:$PATH cd /var/www/vhosts//current bundle exec rake utils:process_archives DIR=/var/www/vhosts//shared/tmp RAILS_ENV=production /var/www/vhosts//shared/log/cron.log 21' Is the scheduler.rb being used at all? Another thing about running the app locally on a development server is when I enable development as shown above, it breaks links to images, css, etc. Seems there is something in the code to prefix the paths of those resources with '/app_development/' when using development environment. So, I'm running in production environment on the development server. Other than references like this in the code for development, what would be the difference between running a copy of the app under the production or development environment on the development server? Again, thanks a ton for any help and patience, I promise to get up to speed as quickly as possible. -- Robert -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/546CD828.700%40webtent.org. For more options, visit https://groups.google.com/d/optout.
Re: [Rails] Rake tasks
On Nov 19, 2014, at 10:49 AM, Robert Fitzpatrick rob...@webtent.org wrote: Then the code uses '#puts something if @verbose' throughout. Like I said, I'm new to ruby, but have used Perl and PHP and other languages before, I hope is what is throwing me off is the # are not comments? This almost looks like @verbose would always be false. What is this piece of code looking for as an argument? You're reading things correctly. # starts a comment @verbose is always false in this code, and would be even if the if were not commented out The code doesn't even make sense as the result of someone trying to comment out something to hard-wire @verbose to one value or the other... -- Scott Ribe scott_r...@elevated-dev.com http://www.elevated-dev.com/ (303) 722-0567 voice -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/7916A893-DF1F-4AC3-B2FC-671319933E6A%40elevated-dev.com. For more options, visit https://groups.google.com/d/optout.
Re: [Rails] Rake tasks
Scott Ribe wrote: On Nov 19, 2014, at 10:49 AM, Robert Fitzpatrickrob...@webtent.org wrote: Then the code uses '#puts something if @verbose' throughout. Like I said, I'm new to ruby, but have used Perl and PHP and other languages before, I hope is what is throwing me off is the # are not comments? This almost looks like @verbose would always be false. What is this piece of code looking for as an argument? You're reading things correctly. # starts a comment @verbose is always false in this code, and would be even if the if were not commented out The code doesn't even make sense as the result of someone trying to comment out something to hard-wire @verbose to one value or the other... OK, that's a relief that I can read the code, thanks for clarifying. To get verbosity, I'll need to do a lot of uncommenting and do line-by-line debuggging :-/ Jason mentioned a debugging tool for Rails 2.0 earlier, what about for this 1.9.3, anything available to help? -- Robert -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/546CDD73.7000501%40webtent.org. For more options, visit https://groups.google.com/d/optout.
Re: [Rails] Rake tasks
On Nov 19, 2014, at 11:12 AM, Robert Fitzpatrick rob...@webtent.org wrote: OK, that's a relief that I can read the code, thanks for clarifying. To get verbosity, I'll need to do a lot of uncommenting and do line-by-line debuggging :-/ Jason mentioned a debugging tool for Rails 2.0 earlier, what about for this 1.9.3, anything available to help? Maybe I missed something earlier in the discussion, but can't you just edit it to: @verbose = true if arg == 'V' -- Scott Ribe scott_r...@elevated-dev.com http://www.elevated-dev.com/ (303) 722-0567 voice -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/705A11D2-2012-4E5D-9819-7EE2B49240C7%40elevated-dev.com. For more options, visit https://groups.google.com/d/optout.
Re: [Rails] Rake tasks
Scott Ribe wrote: On Nov 19, 2014, at 11:12 AM, Robert Fitzpatrickrob...@webtent.org wrote: OK, that's a relief that I can read the code, thanks for clarifying. To get verbosity, I'll need to do a lot of uncommenting and do line-by-line debuggging :-/ Jason mentioned a debugging tool for Rails 2.0 earlier, what about for this 1.9.3, anything available to help? Maybe I missed something earlier in the discussion, but can't you just edit it to: @verbose = true if arg == 'V' Yes, I guess so, and then uncomment all the places in the code where he has #puts something if @verbose I'll give it a try, still trying to figure out how to run the task. I put the app in development environment with the Apache directive and this is all the deprecated info I mentioned and other output when trying to bundle exec, I get Don't know how to build task 'utils:archives'. Is this how I should be trying to run the task? $ bundle exec rake utils:archives --trace Your Gemfile lists the gem sitemap_generator (= 0) more than once. You should probably keep only one of them. While it's not a problem now, it could cause errors if you change the version of just one of them later. Your Gemfile lists the gem backup (= 0) more than once. You should probably keep only one of them. While it's not a problem now, it could cause errors if you change the version of just one of them later. Your Gemfile lists the gem awesome_print (= 0) more than once. You should probably keep only one of them. While it's not a problem now, it could cause errors if you change the version of just one of them later. Your Gemfile lists the gem awesome_print (= 0) more than once. You should probably keep only one of them. While it's not a problem now, it could cause errors if you change the version of just one of them later. DEPRECATION WARNING: Calling set_table_name is deprecated. Please use `self.table_name = 'the_name'` instead. (called from require at /home/robert/.rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.7.4/lib/bundler/runtime.rb:76) DEPRECATION WARNING: Calling set_primary_key is deprecated. Please use `self.primary_key = 'the_name'` instead. (called from require at /home/robert/.rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.7.4/lib/bundler/runtime.rb:76) DEPRECATION WARNING: Calling set_table_name is deprecated. Please use `self.table_name = 'the_name'` instead. (called from require at /home/robert/.rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.7.4/lib/bundler/runtime.rb:76) DEPRECATION WARNING: Calling set_primary_key is deprecated. Please use `self.primary_key = 'the_name'` instead. (called from require at /home/robert/.rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.7.4/lib/bundler/runtime.rb:76) DEPRECATION WARNING: Calling set_table_name is deprecated. Please use `self.table_name = 'the_name'` instead. (called from require at /home/robert/.rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.7.4/lib/bundler/runtime.rb:76) DEPRECATION WARNING: Calling set_primary_key is deprecated. Please use `self.primary_key = 'the_name'` instead. (called from require at /home/robert/.rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.7.4/lib/bundler/runtime.rb:76) DEPRECATION WARNING: Support for Rails 4.0.4 will be dropped from Formtastic 4.0. (called from require at /home/robert/.rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.7.4/lib/bundler/runtime.rb:76) DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from top (required) at /backup/storage/sites/wmnf/wmnf.org/Rakefile:7) DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from top (required) at /backup/storage/sites/wmnf/wmnf.org/Rakefile:7) DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from top (required) at /backup/storage/sites/wmnf/wmnf.org/Rakefile:7) DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as
Re: [Rails] Rake tasks
Robert Fitzpatrick wrote: Maybe I missed something earlier in the discussion, but can't you just edit it to: @verbose = true if arg == 'V' Yes, I guess so, and then uncomment all the places in the code where he has #puts something if @verbose I'll give it a try, still trying to figure out how to run the task. I put the app in development environment with the Apache directive and this is all the deprecated info I mentioned and other output when trying to bundle exec, I get Don't know how to build task 'utils:archives'. Is this how I should be trying to run the task? Never mind my last post, I looked up the command used in cron and made an adjustment to the DIR for my local box and got the expected response. bundle exec rake utils:process_archives V DIR=/tmp I updated the verbose line to recognize the 'V' argument as suggested and it does output the conditional puts lines, but I do get the following at the end rake aborted! Don't know how to build task 'V' The task does appear to complete successfully, with comments if I specify 'V' and without if not, as expected. Is this normal or should I be applying the argument differently? -- Robert -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/546D1585.7090104%40webtent.org. For more options, visit https://groups.google.com/d/optout.
Re: [Rails] Rake tasks
Hello, What are the deprecated messages you are getting? Mike Riley On Tue, Nov 18, 2014 at 1:31 PM, Robert Fitzpatrick rob...@webtent.org wrote: I am new to ruby and maintaining an existing web application. I need to change the FTP server in a task and trying to familiarize myself with rake tasks. The task is in lib/tasks/archives.rake under the namespace utils. I read over a rake tutorial and viewed rake options to try and show information about the task and possibly run it to test. But when I do 'rake -T', I get a lot of DEPRECATED messages and the list afterward does not have my task listed. This is how the task is defined: namespace:utils do snip task :process_archives = :environment do snip But I have no task listed with that name? I tried 'rake -D utils:process_archives' as well and only got the deprecated messages output. I do see the task in the schedule.rb file... ./config/schedule.rb: command %{#{cmd_root} cd /var/www/vhosts//current bundle exec rake utils:process_archives DIR=/var/www/vhosts//shared/tmp RAILS_ENV=production} And the following file: ./script/process_archives.sh:rake utils:process_archives DIR=/var/www/virtual//htdocs//tmp RAILS_ENV=production The Rakefile looks like this: require File.expand_path('../config/application', __FILE__) ::Application.load_tasks Thanks for any help! -- Robert -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/ msgid/rubyonrails-talk/546B909F.8060606%40webtent.org. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAC09tCVp244hccN%2BL6DRowQ%2BT%2ByBJtY9D%3DPLn36djJDdTt6Dcg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: [Rails] Rake tasks
Robert, 1) The same deprecation warnings probably happen when you just run rails c or rails s, right? If so, those are just general deprecation warnings that are happening when you boot up the app. Today, you can ignore them (hence, warning). In the long run, you'll want to fix those as you upgrade gems and refactor code. 2) Custom rake tasks (defined in your app) should have a description above them. You actually put the description on its own line above the line that starts with the word task (slightly confusing). See the section Describing Your Tasks here http://jasonseifer.com/2010/04/06/rake-tutorial You'll notice that desc comes on its own line before the task line. If you fail to put that description in, your Rake task will still run, but it won't show up in the rake -T output. Finally, you probably almost certainly don't want to be running RAILS_ENV=production if you are developing locally on your own machine. And learn to use a debugger-- I recommend byebug if you're using Ruby 2.0 or above, and put byebug at the top of your rake task. Then just run your rask task and verify that you fall into the debugger. (I'm telling you this as a sanity check methodology because you are trying to verify that you know how to run the task) Hope that helps. -Jason On Nov 18, 2014, at 1:31 PM, Robert Fitzpatrick rob...@webtent.org wrote: I am new to ruby and maintaining an existing web application. I need to change the FTP server in a task and trying to familiarize myself with rake tasks. The task is in lib/tasks/archives.rake under the namespace utils. I read over a rake tutorial and viewed rake options to try and show information about the task and possibly run it to test. But when I do 'rake -T', I get a lot of DEPRECATED messages and the list afterward does not have my task listed. This is how the task is defined: namespace:utils do snip task :process_archives = :environment do snip But I have no task listed with that name? I tried 'rake -D utils:process_archives' as well and only got the deprecated messages output. I do see the task in the schedule.rb file... ./config/schedule.rb: command %{#{cmd_root} cd /var/www/vhosts//current bundle exec rake utils:process_archives DIR=/var/www/vhosts//shared/tmp RAILS_ENV=production} And the following file: ./script/process_archives.sh:rake utils:process_archives DIR=/var/www/virtual//htdocs//tmp RAILS_ENV=production The Rakefile looks like this: require File.expand_path('../config/application', __FILE__) ::Application.load_tasks Thanks for any help! -- Robert -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/546B909F.8060606%40webtent.org. For more options, visit https://groups.google.com/d/optout. Jason Fleetwood-Boldt t...@datatravels.com http://www.jasonfleetwoodboldt.com/writing All material © Jason Fleetwood-Boldt 2014. Public conversations may be turned into blog posts (original poster information will be made anonymous). Email ja...@datatravels.com with questions/concerns about this. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/65B0E024-3594-48E7-B1DA-97F88A62D7D7%40datatravels.com. For more options, visit https://groups.google.com/d/optout.
Re: [Rails] Rake tasks
Jason Fleetwood-Boldt wrote: Finally, you probably almost certainly don't want to be running RAILS_ENV=production if you are developing locally on your own machine. And learn to use a debugger-- I recommend byebug if you're using Ruby 2.0 or above, and put byebug at the top of your rake task. Then just run your rask task and verify that you fall into the debugger. (I'm telling you this as a sanity check methodology because you are trying to verify that you know how to run the task) Thanks for the info and help. The app is on ruby 1.9.3, I was running rake on the production machine. I downloaded the app and have it running locally, but there are some display issues with development, so I was running production. I see the task is running via cron every hour, it talks to an ftp server and gets a file list, then creates playlist files from the list of MP3 files it finds. I see the task has a lot of puts when 'ARGV = V', should I be able to run the task with the following command? # rake utils:process_archive V' -- Robert -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/546BAD1C.80003%40webtent.org. For more options, visit https://groups.google.com/d/optout.
Re: [Rails] Rake tasks
Without seeing the task I can't tell you the answer to that. And the fact that it runs on a cron schedule means that you probably have something like a worker in the background doing that. Normally you run rake some_task X=abc Y=xyz where X and Y are arguments being passed in. But note that you probably want to prefix the rake task in development with bundle exec to get it to run with the right gemset. -Jason On Nov 18, 2014, at 3:33 PM, Robert Fitzpatrick rob...@webtent.org wrote: Jason Fleetwood-Boldt wrote: Finally, you probably almost certainly don't want to be running RAILS_ENV=production if you are developing locally on your own machine. And learn to use a debugger-- I recommend byebug if you're using Ruby 2.0 or above, and put byebug at the top of your rake task. Then just run your rask task and verify that you fall into the debugger. (I'm telling you this as a sanity check methodology because you are trying to verify that you know how to run the task) Thanks for the info and help. The app is on ruby 1.9.3, I was running rake on the production machine. I downloaded the app and have it running locally, but there are some display issues with development, so I was running production. I see the task is running via cron every hour, it talks to an ftp server and gets a file list, then creates playlist files from the list of MP3 files it finds. I see the task has a lot of puts when 'ARGV = V', should I be able to run the task with the following command? # rake utils:process_archive V' Jason Fleetwood-Boldt t...@datatravels.com http://www.jasonfleetwoodboldt.com/writing All material © Jason Fleetwood-Boldt 2014. Public conversations may be turned into blog posts (original poster information will be made anonymous). Email ja...@datatravels.com with questions/concerns about this. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/94468783-F843-4093-9691-9D98ABC415A6%40datatravels.com. For more options, visit https://groups.google.com/d/optout.