-
Notifications
You must be signed in to change notification settings - Fork 0
Getting started in a stand alone project
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
.
The name you pass will be the name of the app that shows up in AWS and the name of the directory in which your new files
will live. When you deploy to AWS the stage (dev, staging, production, etc...) will be included, so you don't need to worry
about that at this stage.
funktor bootstrap my-funktor-app
The command above will create a file at my-funktor-app/funktor_init.yml
. You can edit that file to tweak some of the defaults
or to add more work queues. Don't worry about changing anything on your first pass, you can always go back and tweak things later.
Once you've tweaked that file it's time to generate the reset of your app. Make sure you're in your new app directory and then run
funktor init
.
cd my-funktor-app
funktor init
This will generate a serverless.yml
file and a bunch of support files that it uses to provision and configure AWS resources.
Next do a quick bundle install
to get your apps gems installed from the Gemfile
and npm install
to get
the serverless deployment framekwork all ready to go.
bundle install
npm install
Now you're ready to 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
If you want to deploy to a different stage you can use the --stage
or -s
flag.
serverless deploy -s staging
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.