npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

serverless-spotinst-functions

v1.1.3

Published

Spotinst Functions is a Multi-Cloud Functions-as-a-Service (FaaS) platform that utilizes affordable compute and network infrastructure. Spotinst will take care of everything required to run and scale your code with high availabilty across all cloud provid

Downloads

51

Readme

Serverless - Spotinst Functions

Spotinst Functions is a Multi-Cloud Functions-as-a-Service (FaaS) platform that utilizes affordable compute and network infrastructure. Spotinst will take care of everything required to run and scale your code with high availabilty across all cloud providers (AWS, Azure, Google Cloud, IBM Cloud, Oracle, and Equinix.)

Functions are independent units of deployment, like microservices. They are code deployed and the cloud written to perform a specific job.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system. For more information, please see the Serverless provider documentation. for Spotinst.

Prerequisites

You will need a Spotinst Account and Spotinst API token to complete setup. Sign up for a Spotinst Account here. You can create your API token by navigating to My Account>API and selecting generate token. Note: You only need to set up your credentials once.

img

img

Installing

First, install the serverless framework.

npm install -g serverless

Next, set up your credentials. You'll need to have the Spotinst Serverless plugin already installed inside a new Serverless project. Create a new template project and specify the directory with --path

serverless create --template spotinst-nodejs --path new-service

Install node modules from within the directory (in this example: /new-service)

npm install

If this is your first Functions project, you need to configure your credentials. Enter your Spotinst Account and API token:

serverless config credentials --provider spotinst --token {Your Spotinst API Token} --account {Your Spotinst Account ID}

Double-check that your credentials are properly set up:

cat ./spotinst/credentials

You should see the account ID and token.

Deployment

Deploying a project places it into production and allows you to see and edit it in the Spotinst Console. In order to deploy, you will need to associate the function with an environment in the Spotinst Console. The environment ID can be found on the Spotinst Console under Functions. In this menu you will be able to add applications, environments, and functions. An application is a collection of one or more environments, and an environment is a collection of one or more functions. Use this structure to organize projects in a way that best suits your needs.

Select the application and environment to see the environment ID. Copy-paste this ID into your severless.yml file. Don't forget to change your function name before deploying!

img

service: your-service

provider:
  name: spotinst
  spotinst:
    environment: {environment ID} # ex: env-123456

functions:
  hello:  # this defaults to hello, don't forget to change it!
    runtime: nodejs8.3
    handler: handler.main
    memory: 128
    timeout: 30
    access: private

With that set, you can deploy (and later, update) the service with the same command:

serverless deploy

To deploy/update a single function, use:

serverless deploy -f hello

Invoking the function

You can invoke the function from the Spotinst Console and from the command line. To invoke from the command line, run:

serverless invoke -f hello

To use the Spotinst Console, select the function from within the Application and Environment menu and click 'run test' from the 'Test' tab.

Additionally, if you change the access parameter to 'public' in your function's serverless.yml file, you can invoke your function using the generated HTTP endpoint, found under the 'Triggers' tab in the Console. Also under 'Triggers' is the ability to add a CRON trigger for running the function at a regular interval.

img

Logs

Logs are viewable in the 'Logs' section of each function on the Spotinst Console. There is a small time lag between function invokation and logs appearing in the list.

You can see the logs for a given function from the command line. Use the --startTime option to denote a unit of time.

serverless logs -f hello --StartTime 3h

This command will show you the past 3 hours worth of logs for the function hello.

Cleanup

If you no longer need your service, run the remove command to ensure you don't incur any unexpected charges:

serverless remove