I have a ruby script open.rb
require 'launchy'
Launchy.open("http://stackoverflow.com")
Now what i want is that in a day i run script first time than it should run after every 10 minute.
so is there any way to do this and here i am using windows 7.
After google on this i got a way to do it Ruby on Rails with worker as a background job but that is not my solution so is there any possible way to do it or is there any gem to do this task.
and also how can i clear chache before running this.
The solution is to use Windows Scheduler.
To set the task run every 10 minutes, follow the solution in this Stack Overflow question: windows scheduler to run a task every x-minutes?
UPDATE: here is a way to run associate Ruby script to ruby.exe : https://stackoverflow.com/a/1422398/188331 ( you can make a batch script )
Related
When using vagrant machines with test-kitchen the pre_create_command allows you to specify a command which is run locally before the vagrant machine is being created. With kitchen-docker no such configuration option seems to exist, and bending chef_omnibus_url as suggested here isn't an option.
The script specified as pre_create_command for the testing vagrants generates a local chef data bag.
Is there a solution around which I've overlooked?
Best practices include Rakefile and Thor.
In essence you control your tests from a Rakefile. For example:
rake style
This will run all commands under your style task (maybe lint/syntax/unit and kitchen tests). Of course you can modify your tasks to perform whatever you like. Here are some good resources:
https://blog.chef.io/2015/04/21/overview-of-test-driven-infrastructure-with-chef/
See the Supporting Tools and Dependencies section.
Here is an example Rakefile:
https://github.com/chef-cookbooks/chef-server/blob/master/Rakefile
I sketched a patch for kitchen-docker here. However, as the discussion on this pull request shows, there are arguments against an appropriate functionality in kitchen-docker, namely the one that such functionality (if ever) should go in the kitchen core.
So for the time being we have to live with this inconsistency between docker and vagrant, and this is where thun's answer comes into play.
This can be done using
driver_config:
provision_command: <command>
in kitchen.yml
Check more here
Kr,
Rshad
I have an iphone app that uses a rails backend to grab data from. Is it possible to have a before start hook for tests that start the rails server?
Why not use the pre-action in the Test command? You'll need to hit that + and add the New Run Script Action.
The only drawback is you can't abort the test if you cannot start the test. You can see a thread about that here: Is it normal for Xcode not to detect if a pre-action failed?
How can you run WEBrick servers in the background as a Windows service? I tried following the advice in this post, but I am using Rails 3, and couldn't come up with an equivalent to C:\RUBYAPP\script\server -e production, since the server directory doesn't exist in Rails 3 anymore. Any help?
I have never seen WEBrick used in Windows services but a workaround could be running the web server as a background job. This is how you would do it:
You'll need a bat file with the 2 instructions to start the web server:
cd to_your_absolute_app_path
rails s
Then you'll need to convert that bat file to an exe file. Check this for a free tool. I know the tool exists for 32 and 64 bits, you might need to look around for the right one.
When you create the exe make sure to select it to run as an invisible app.
Then you put the exe in the start up folder. That should do it.
I am having a problem with the ExecJS in that it is unable to locate a required Runtime. I am using Windows, and I have both Windows CScript and Node.js installed on my computer, but neither of these guys are being invoked.
As a result, I am unable to run any rails task that involves this (I cannot even load my rake list in RubyMine to call actions such as db:create to create my databases from a fresh project.)
I am capable of accessing both csript and node from the command line, and I have checked my environment variables and their proper file locations are in the PATH. There's something else ruining my ability to use ExecJS. Has anyone else had a similar experience where you have had all of the right stuff, but something is still going wrong?
When Ruby spawns child process to invoke CScript or Node, it will use the same rules that allow cmd.exe execute them from the command line.
But, sometimes, stuff in your registry or your environment variables can affect this process.
At RubyInstaller project we collected a series of troubleshooting items that could possible be the culprit.
Please check that COMSPEC environment variable is set to use cmd.exe and nothing like TCC/LE or other stuff.
C:\>SET COMSPEC
Also, check that your registry do not contain an AutoRun key, which will also affect Ruby.
C:\>REG QUERY "HKCU\Software\Microsoft\Command Processor"
C:\>REG QUERY "HKLM\Software\Microsoft\Command Processor"
If you see a key AutoRun in one of the above commands, that means something is setup to automatically execute everytime a new cmd.exe is started, which is bad for some cases.
Please follow the instructions in the Troubleshooting page on how to remove it.
This also affects gem installation that requires compilation, but if is not failing for you then the problem might be something else.
Hope that helps.
I was having similar problems, my basic skeleton app wouldn't run despite having Node.js installed, and then trying therubyracer gem. Finally I decided to use my troubleshooting mantra with windows, "When in doubt, run as admin". So I ran my rails cmd as an admin and it worked fine after that.
I'm trying to automate a ruby app deployment on a Windows machine with a batch script.
Everything is going dandy, except for the following line:
gem install bundler
If I type this in manually, all goes well. If I use a batch script, however, the process is killed as soon as the installation completes. This is what I'm using:
pause
gem install bundler --no-ri --no-rdoc
pause
I've tried with the -f switch and also all docs; nothing seems to prevent the window from getting killed. I need the process to stay alive so I can bundle install. Any idea why this is happening, and how I can keep it alive post-install?
gem is a batch file (gem.bat). When you're invoking a batch file from another one, it is transferring control to it and not resuming.
You should try using CALL instead:
CALL a second batch file
The CALL command will launch a new batch file context along with any specified arguments.
When the end of the second batch file is reached (or if EXIT is used), control will return
to just after the initial CALL statement.
Documentation here:
http://ss64.com/nt/call.html
You can also avoid the batch file by doing ruby -S gem ... which is more verbose and will work since there is a gem (extensionless) file along gem.bat.
Hope that helps.