Step 1: Sign Up for a Free SimpleWorker Account
Step 2: Create a Project
Step 3: Install the SimpleWorker GemInstall the SimpleWorker Ruby gem in your dev environment. You'll be creating worker jobs and sending them to SimpleWorker from your application. (Note that SimpleWorker works with Ruby >v 1.9. It will not work with earlier versions.) Install the gem:
Step 4: Create a WorkerCreate a file calledmy_worker.rb and enter the following:
The run method is what gets called when the worker runs. Now that we have a worker that does something, so let's run it. Step 5: Run it locally to make sure it worksCreate another file called r The v2 version of the SimpleWorker gem takes a token and a project_ID for authorization. Tokens can be found on the API Tokens tab under the Account link. Your project IDs can be found on the projects page.
Now run the worker with:
Does your script run ok locally? If so, then it's time to send it off to SimpleWorker to run it in the cloud. Step 6: Send it to the Cloud!With a tiny little change to Comment out the
Now run it again with:
It should initialize and upload your worker to SimpleWorker to run in the cloud. Step 7: View the Status of Worker JobClick the "Jobs" tab in the SimpleWorker dashboard and you'll see the status of your worker! It should either be running or completed. That's all there is to it!
SimpleWorker is multi-tenant system processing thousands and hundreds of thousands of jobs across many users on many servers. SimpleWorker offers multiple priority levels to make sure you get the best combination of performance/value for your tasks. Standard priority (p0) is often used for processing thousands of tasks -- crawling or indexing pages -- where some minutes in the queue does not have a material effect. For tasks that are time-sensitive (such as offloading front-end tasks or when in dev/test mode), we recommend you run in p1 or p2 to run tasks faster. For example, specifying a higher priority will move tasks ahead of p0 tasks:
Extra Credit - Using SchedulesAnother key aspect of SimpleWorker is the ability to schedule jobs to run later. There are a number of options to use so that you can run them once or on a recurring schedule.
|
Ruby > Getting Started >