Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A convenient Node.js wrapper to interact with fly.io CLI.

License

NotificationsYou must be signed in to change notification settings

Kikobeats/flyctl

Repository files navigation

Last versionNPM Status

A convenient Node.js wrapper to interact withfly.io CLI.

Install

$ npm install flyctl --save

Usage

First, call the library passig the app name of your project:

constfly=require('flyctl')('teslahunt-api')

Once initialized, you can interact with anyfly CLI command via Node.js.

You can run a one-off command:

const{ stdout}=awaitfly('scale show')console.log(stdout)

or pipe directly into your Node.js process usingfly.stream():

fly.stream('logs')

Additionally, you can usefly.json() to return a JSON payload of the command.

This is convenient for combining multiple command and create your own commands:

constCPU_CORES=1constCPU_KIND='shared'constMEMORY_IN_BYTES=768constRESTART_POLICY='always'constmachineList=awaitfly.json('machine list')constmachines=machineList.map(({ id, config})=>({ id,zone:config.env.FLY_PROCESS_GROUP}))for(const{ id}ofmachines){awaitfly(`machine update${id} --vm-cpus${CPU_CORES} --vm-cpu-kind${CPU_KIND} --vm-memory=${MEMORY_IN_BYTES} --restart${RESTART_POLICY} --yes`)}

Seeexamples.

API

constructor(appName, [options])

appName

Required
Type:string

The name of yourfly.io application.

options

verbose

Type:boolean
Default:true

Print the raw fly command every time it's executed.

binaryPath

Type:string
Default:process.env.FLY_PATH

It sets where is theflyctl binary path.

fly(cmd, spawnOpts)

It runs the command provided and buffer the output.

It accepts a second argument to be passed tochild_process.spawn#options.

fly.stream(cmd)

It runs the command provided, streaming the output to the parent process.

fly.json(cmd)

It runs the command provided, parsing the stdout into a JSON.

License

flyctl ©Kiko Beats, released under theMIT License.
Authored and maintained byKiko Beats with help fromcontributors.

kikobeats.com · GitHubKiko Beats · Twitter@kikobeats

About

A convenient Node.js wrapper to interact with fly.io CLI.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp