Skip to content

v57/hub-launcher

Repository files navigation

Containerization logo  Launcher

Made for Hub

Manage and run the apps in your Hub network. It's primarily used to launch Hub and it's services and keep them alive.

Implemented features:

  • Installs Hub Lite server by default with the option to upgrade to Pro
  • Add installation, uninstallation, check for updates, update and launch shell scripts and use it from Hub app
  • Use bun preset to easily install bun and use scripts from GitHub
  • Watch process cpu and memory usage
  • Set environment values for each process
  • Secret environment values
  • Check for updates and update your commands easily from Hub
  • Start and stop processes when you need
  • Set number of processes you want to run

Run from Source

bun install && bun .

Run from Hub cli

bunx v57/hub

Stop with

bunx v57/hub stop

Run from Docker

docker build -t hub .
docker run -d --name hub -p 1997:1997 -e HUBLISTEN=0.0.0.0:1997 --restart=always hub

Api usage

Watch app info

for await (const info of service.values('launcher/info')) {
  // { apps: App[] }
}

Watch app status

for await (const status of service.values('launcher/status')) {
  // { apps: AppStatus[] }
}

Update and restart apps

await service.send('launcher/update/check')
await service.send('launcher/update/check/all')
await service.send('launcher/update/all')
await service.send('launcher/stop')

Manage individual apps

await service.send('launcher/app/start', 'Hub Lite')
await service.send('launcher/app/stop', 'Hub Lite')
await service.send('launcher/app/restart', 'Hub Lite')
await service.send('launcher/app/uninstall', 'Hub Lite')

Install or configure apps

await service.send('launcher/app/create', {
  name: 'My App',
  type: 'bun',
  repo: 'v57/my-app',
  active: true,
})

await service.send('launcher/app/settings', {
  app: 'My App',
  settings: {
    env: {
      PORT: '3000',
    },
  },
})

await service.send('launcher/app/cluster', {
  name: 'My App',
  count: 3,
})

Upgrade Hub

await service.send('launcher/pro', 'your-owner-key')

Launch config

launch.json stores the managed apps.

interface AppSettings {
  env?: Record<string, string | undefined>
  secrets?: Record<string, string | undefined>
}

interface BunApp {
  name: string
  type: 'bun'
  repo: string
  command?: string
  commit?: string
  env?: Record<string, string>
  envValues?: Record<string, string>
  active?: boolean
  restarts?: boolean
  instances?: number
  settings?: AppSettings
}

interface ShellApp {
  name: string
  type: 'sh'
  run: string
  directory?: string
  install?: string[] | string
  checkForUpdates?: string[] | string
  update?: string[] | string
  uninstall?: string[] | string
  env?: Record<string, string>
  envValues?: Record<string, string>
  active?: boolean
  restarts?: boolean
  instances?: number
  settings?: AppSettings
}

type AppSetup = BunApp | ShellApp

Status shape

interface AppStatus {
  name: string
  checkingForUpdates?: boolean
  updating?: boolean
  crashes: number
  processes: ProcessStatus[]
  started?: Date
}

interface ProcessStatus {
  pid: number
  cpu: number
  memory: number
}

Example launch file

[
  {
    "name": "Hub Lite",
    "type": "bun",
    "command": "start",
    "repo": "v57/hub-lite",
    "active": true
  },
  {
    "name": "Google",
    "type": "bun",
    "repo": "v57/hub-google",
    "active": true
  },
  {
    "name": "MongoDB",
    "type": "sh",
    "run": "/usr/local/bin/mongod --dbpath ~/mongo",
    "active": true
  }
]

About

Keeps your hub and services online

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors