mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2026-02-23 10:30:06 -06:00
* feat: init lago client * feat: billable meter * feat: db persistence * wip: expose sub * feat: rename page * wip: billing section * wip: lago integration * feat: separate plan and period * wip: webhook * feat: improve empty state * feat: update limits on plan changes * feat: can change plans * feat: change plan loading state * feat: yearly filter * feat: billing clarification * fix: treatment * feat: filter plans * feat: prevent non-owner from changing plan * fix: loading state * fix: jit portal link * fix: rm import * fix: build errors * fix: default to free * fix: wrong files * fix: select or insert customer * fix: note * feat: upgrade dependent on payment method state * fix: dedupe * chore: remove github-app from core * chore: port to cloud * chore: port to cloud * chore: port to cloud * chore: port to cloud * chore: port to cloud * add new components, repository callbacks * chore: rm unused packages * chore: fix generation * chore: gen * fix: cloud api references * debug * debug * fix: actually set plans * chore: rm debug * fix: build * feat: callbacks * fix: add generated code * chore: group cloud components * chore: group by feature * feat: alert change * feat: confirm * fix: confirm modal * fix: ui * fix: remove arrears * fix: open in same tab * fix: wan alert * fix: call the callback * fix: callback obj * fix: disable if no cloud meta --------- Co-authored-by: Alexander Belanger <alexander@hatchet.run>
49 lines
948 B
Go
49 lines
948 B
Go
package api
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/hatchet-dev/hatchet/api/v1/server/run"
|
|
"github.com/hatchet-dev/hatchet/pkg/config/loader"
|
|
)
|
|
|
|
func Start(cf *loader.ConfigLoader, interruptCh <-chan interface{}) error {
|
|
// init the repository
|
|
configCleanup, sc, err := cf.LoadServerConfig()
|
|
if err != nil {
|
|
return fmt.Errorf("error loading server config: %w", err)
|
|
}
|
|
|
|
var teardown []func() error
|
|
|
|
runner := run.NewAPIServer(sc)
|
|
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
apiCleanup, err := runner.Run()
|
|
if err != nil {
|
|
return fmt.Errorf("error starting API server: %w", err)
|
|
}
|
|
|
|
teardown = append(teardown, apiCleanup)
|
|
teardown = append(teardown, configCleanup)
|
|
|
|
sc.Logger.Debug().Msgf("api started successfully")
|
|
|
|
<-interruptCh
|
|
|
|
sc.Logger.Debug().Msgf("api is shutting down...")
|
|
|
|
for _, teardown := range teardown {
|
|
if err := teardown(); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
sc.Logger.Debug().Msgf("api successfully shut down")
|
|
|
|
return nil
|
|
}
|