Skip to content

Getting started in a rails project

Jeremy Green edited this page Jun 9, 2021 · 3 revisions

Install serverless

npm install -f serverless

Install funktor

gem install funktor

Initialize a new app, passing the name of the app you want to creat. In this case the name of the app is my-funktor-app.

funktor init my-funktor-app

Now go into your new app directory, and deploy your app to the dev stage. This is where you can test your code running directly on AWS. (Later when you're ready to put your app into production you can deploy to the production stage. You can also create other stages like staging if you need to.)

serverless deploy -v

After your app is deployed you'll see some outputs containing details about your AWS resources. The primary ones you should look for are IncomingJobQueueUrl, AccessKeyID, and SecretAccessKey. Those three pieces of info represent the primary interface to your funktor app from the outside world.

To push your first job to funktor you can make note of those values and then run bundle console and do this:

ENV['FUNKTOR_INCOMING_JOB_QUEUE'] = "<Your IncomingJobQueueUrl>"
ENV['AWS_ACCESS_KEY_ID'] = "<Your AccessKeyID>"
ENV['AWS_SECRET_ACCESS_KEY'] = "<Your SecretAccessKey>"
ENV['AWS_REGION'] = "<Your AWS Region>" # 'us-east-1' by default

require_relative 'workers/hello_worker'
HelloWorker.perform_async

If everything went well you should see something like this:

=> #<struct Aws::SQS::Types::SendMessageResult md5_of_message_body="...",
  md5_of_message_attributes=nil, md5_of_message_system_attributes=nil,
  message_id="...", sequence_number=nil>

And if you go into your AWS web console you should find a log in CloudWatch.

Clone this wiki locally