@ts-cloud/core 0.16.58 → 0.16.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/types.d.ts +126 -0
  2. package/package.json +2 -2
package/dist/types.d.ts CHANGED
@@ -521,6 +521,31 @@ export interface InfrastructureConfig {
521
521
  * }
522
522
  */
523
523
  compute?: ComputeConfig;
524
+ /**
525
+ * Dedicated machines that are not app servers - a CI runner, a build box.
526
+ *
527
+ * Each is a named server ts-cloud finds or creates (an existing server with
528
+ * the same name is adopted, never recreated), with the packages it needs
529
+ * installed through pantry and its long-running processes as systemd user
530
+ * units of an unprivileged account. Re-applying a declaration converges the
531
+ * box: missing packages are installed, changed units are rewritten, and a
532
+ * running service is left running unless it asked to be restarted.
533
+ *
534
+ * @example
535
+ * boxes: {
536
+ * runner: {
537
+ * name: 'ci-runner-1',
538
+ * size: 'cx23',
539
+ * location: 'fsn1',
540
+ * packages: ['google.com/chrome@155.0.8059.84'],
541
+ * user: { name: 'runner' },
542
+ * services: {
543
+ * 'ci-runner': { exec: '%h/ci-runner', environmentFile: '%h/.config/ci-runner.env' },
544
+ * },
545
+ * },
546
+ * }
547
+ */
548
+ boxes?: Record<string, BoxConfig>;
524
549
  /**
525
550
  * Container configuration (ECS Fargate)
526
551
  * Defines containerized services for serverless deployment mode
@@ -3025,6 +3050,107 @@ export interface ContainerItemConfig {
3025
3050
  targetMemoryUtilization?: number;
3026
3051
  };
3027
3052
  }
3053
+ /** A long-running process on a {@link BoxConfig}, run as a systemd unit. */
3054
+ export interface BoxServiceConfig {
3055
+ description?: string;
3056
+ /** `ExecStart`. `%h` is the service user's home. */
3057
+ exec: string;
3058
+ /** @default '%h' */
3059
+ workingDirectory?: string;
3060
+ /** Non-secret variables, written to an env file only the service user can read. */
3061
+ environment?: Record<string, string>;
3062
+ /**
3063
+ * An env file on the box that ts-cloud references but never writes - for
3064
+ * credentials minted on the machine (a runner's registration token).
3065
+ */
3066
+ environmentFile?: string;
3067
+ /** Directories prepended to the service's PATH, ahead of the pantry packages. */
3068
+ path?: string[];
3069
+ /** @default 'always' */
3070
+ restart?: 'always' | 'on-failure' | 'no';
3071
+ /** @default 10 */
3072
+ restartSec?: number;
3073
+ /**
3074
+ * Restart a running service when its unit or environment changed.
3075
+ * Off by default: a converge must never kill the job a runner is in the
3076
+ * middle of. Restart it yourself, gracefully, when it is idle.
3077
+ * @default false
3078
+ */
3079
+ restartOnChange?: boolean;
3080
+ /**
3081
+ * The signal that asks this service to finish its work and exit, such as
3082
+ * a CI runner's `SIGUSR2` (finish the current job, claim no other).
3083
+ * Before a {@link BoxConfig.resize} powers the box off, each such service
3084
+ * gets it and the resize waits for the process to exit, then stops the
3085
+ * unit so `Restart=` cannot start it again and claim more work. Services
3086
+ * without one are stopped by the shutdown itself.
3087
+ */
3088
+ drainSignal?: string;
3089
+ /**
3090
+ * How long a drain may take before the resize gives up, with the box
3091
+ * left running as it was.
3092
+ * @default 3600
3093
+ */
3094
+ drainTimeoutSec?: number;
3095
+ }
3096
+ /** A dedicated machine declared under `infrastructure.boxes`. */
3097
+ export interface BoxConfig {
3098
+ /** Server name; an existing server with this name is adopted. */
3099
+ name: string;
3100
+ /** Provider server type (Hetzner `cx23`, ...). */
3101
+ size: string;
3102
+ location?: string;
3103
+ /** @default 'ubuntu-24.04' */
3104
+ image?: string;
3105
+ /** Ingress besides SSH. */
3106
+ ports?: Array<{
3107
+ protocol: 'tcp' | 'udp' | 'icmp';
3108
+ port?: number;
3109
+ }>;
3110
+ /** Pin the pantry CLI. @default latest release */
3111
+ pantryVersion?: string;
3112
+ /** Pantry package specs (`domain` or `domain@version`), installed into /opt/pantry. */
3113
+ packages?: string[];
3114
+ /**
3115
+ * Free space the root filesystem must have before packages are installed.
3116
+ * Below it the converge installs nothing and says so: a package tree that
3117
+ * fills the disk takes down whatever else the box is doing (on a CI runner,
3118
+ * every job). Pantry's Chrome alone unpacks to about 5 GB on Linux.
3119
+ * @default 10
3120
+ */
3121
+ minFreeDiskGb?: number;
3122
+ /** The unprivileged account services run as. Without it, services are system units run as root. */
3123
+ user?: {
3124
+ name: string;
3125
+ /** Supplementary groups (e.g. `docker`), added if they exist. */
3126
+ groups?: string[];
3127
+ };
3128
+ services?: Record<string, BoxServiceConfig>;
3129
+ labels?: Record<string, string>;
3130
+ /**
3131
+ * Change an existing server to {@link BoxConfig.size}. Without it a
3132
+ * declared size only applies when the box is created: resizing powers the
3133
+ * box off, so it never happens by accident. Services with a
3134
+ * {@link BoxServiceConfig.drainSignal} are drained first.
3135
+ */
3136
+ resize?: {
3137
+ /** Enlarge the disk with the type. It cannot be shrunk again. @default true */
3138
+ upgradeDisk?: boolean;
3139
+ /**
3140
+ * When the provider reports no stock of the type: `'fail'`, or
3141
+ * `'keep-current'` to leave the box as it is and converge it anyway.
3142
+ * @default 'fail'
3143
+ */
3144
+ whenUnavailable?: 'keep-current' | 'fail';
3145
+ /**
3146
+ * Ask for the type even when the provider's stock flag says none is
3147
+ * left. The flag is best effort; if placement does fail, the box is
3148
+ * powered on again as it was.
3149
+ * @default false
3150
+ */
3151
+ attemptUnavailable?: boolean;
3152
+ };
3153
+ }
3028
3154
  export interface ComputeConfig {
3029
3155
  /** Explicitly reconcile an existing Hetzner server's size. Never resize by default. */
3030
3156
  resize?: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ts-cloud/core",
3
3
  "type": "module",
4
- "version": "0.16.58",
4
+ "version": "0.16.62",
5
5
  "description": "Core CloudFormation generation library for ts-cloud",
6
6
  "author": "Chris Breuer <chris@stacksjs.com>",
7
7
  "license": "MIT",
@@ -31,7 +31,7 @@
31
31
  "typecheck": "tsc --noEmit"
32
32
  },
33
33
  "dependencies": {
34
- "@ts-cloud/aws-types": "0.16.58"
34
+ "@ts-cloud/aws-types": "0.16.62"
35
35
  },
36
36
  "devDependencies": {
37
37
  "typescript": "^7.0.2"