Skip to content

Commit

Permalink
Revert cli command foreground to run
Browse files Browse the repository at this point in the history
  • Loading branch information
Hexagon committed Apr 14, 2024
1 parent 9e4c80f commit e0cbdd9
Show file tree
Hide file tree
Showing 15 changed files with 48 additions and 47 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ create a simple instance running a single process:

`pup append --id "my-task" --cmd "deno run -A task.ts" --cron "0 0 * * * *"`

3. (Optional) Test run your instance (ecosystem):
3. (Optional) Test run your instance:

`pup foreground`
`pup run`

4. To make your instance run at boot, enable it using `pup enable-service`.

Expand All @@ -62,9 +62,9 @@ For the full manual, see <https://pup.56k.guru>

It is also possible to use pup to keep a process alive temporary, without a `pup.json` or system service.

To achieve this, use `pup foreground` with `--cmd` and a start policy, the default restart policy is `--autostart`.
To achieve this, use `pup run` with `--cmd` and a start policy, the default restart policy is `--autostart`.

`pup foreground --cmd "deno run server.ts"`
`pup run --cmd "deno run server.ts"`

## Example setups

Expand Down
43 changes: 22 additions & 21 deletions docs/src/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ nav_order: 13

All notable changes to this project will be documented in this section.

## [1.0.0-rc.19] - 2024-04-14
## [1.0.0-rc.19] - Unreleased

- chore(core): Make environment variable code cross-runtime.
- change(cli): Revert cli command `foreground` to `run`

## [1.0.0-rc.18] - 2024-04-14

Expand All @@ -23,32 +24,32 @@ All notable changes to this project will be documented in this section.

### Breaking Changes

- [x] change(cli): Rename cli command run to foreground to not be confused with starting as a service
- [x] change(cli): Rename cli command install to enable-service to separate from actual pup installation
- [x] change(cli): Rename cli command uninstall to disable-service to separate from actual pup uninstallation
- [x] change(config): Support JSON5.
- [x] change(core): Move .pup.jsonc-tmp, .pup.jsonc-data into .pup
- [x] change(packaging): Move default installation docs/references from `deno.land/x` to JSR.io
- change(cli): Rename cli command `run` to `foreground` to not be confused with starting as a service
- change(cli): Rename cli command `install` to `enable-service` to separate from actual pup installation
- change(cli): Rename cli command `uninstall` to `disable-service` to separate from actual pup uninstallation
- change(config): Support JSON5.
- change(core): Move .pup.jsonc-tmp, .pup.jsonc-data into .pup
- change(packaging): Move default installation docs/references from `deno.land/x` to JSR.io

### Non-breaking

- [x] fix(core): Foreground command did not keep an autostarted process running, fixed by refing the watchdog timer.
- [x] fix(cli): Controlled output of manual rests after installing/uninstalling as service.
- [x] fix(docs): Docs incorrectly stated that `**/_._` is default for watcher config. `**/*.*` is correct.
- [x] fix(schema): Expect Record<string, string> for process.env in json schema.
- [x] change(core): Make most code cross runtime, preparing for Node and Bun support.
- fix(core): run command did not keep an autostarted process running, fixed by refing the watchdog timer.
- fix(cli): Controlled output of manual rests after installing/uninstalling as service.
- fix(docs): Docs incorrectly stated that `**/_._` is default for watcher config. `**/*.*` is correct.
- fix(schema): Expect Record<string, string> for process.env in json schema.
- change(core): Make most code cross runtime, preparing for Node and Bun support.

## Maintenance

- [x] chore(deps): Replace `deno.land/x/udd` with `@check/deps`
- [x] chore(deps): Use `@cross/deps` for cross-runtime filesystem operations
- [x] chore(deps): Replace `deno.land/x/hexagon/service` with `@cross/service` for cross-runtime service installation
- [x] chore(deps): Replace `deno.land/x/std/` with `@std/` from jsr
- [x] chore(deps): Replace `deno.land/x/dax` with `dax-sh` for a cross runtime shell
- [x] chore(deps): Replace `deno.land/x/zod` with `npm:zod`
- [x] chore(deps): Utilize `@cross/utils` instead of Deno built-ins for cross runtime ansi console output, argument parsing, process management and more.
- [x] chore(deps): Use `@cross/env` to handle enviroment variables across runtimes.
- [x] chore(testing): Use `@cross/test` insted of Deno test runner, to utilize the native test runners of Node, Deno and Bun.
- chore(deps): Replace `deno.land/x/udd` with `@check/deps`
- chore(deps): Use `@cross/deps` for cross-runtime filesystem operations
- chore(deps): Replace `deno.land/x/hexagon/service` with `@cross/service` for cross-runtime service installation
- chore(deps): Replace `deno.land/x/std/` with `@std/` from jsr
- chore(deps): Replace `deno.land/x/dax` with `dax-sh` for a cross runtime shell
- chore(deps): Replace `deno.land/x/zod` with `npm:zod`
- chore(deps): Utilize `@cross/utils` instead of Deno built-ins for cross runtime ansi console output, argument parsing, process management and more.
- chore(deps): Use `@cross/env` to handle enviroment variables across runtimes.
- chore(testing): Use `@cross/test` insted of Deno test runner, to utilize the native test runners of Node, Deno and Bun.

## [1.0.0-rc.14] - 2024-04-07

Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/basic-webinterface/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ intallation, you **can not** use the `$VERSION` variable, and should give an abs

`cd` to `/docs/src/examples/basic-webinterface` directory.

Start example by running `pup foreground` if pup is installed, or something like `deno run -A ../../../pup.ts foreground` if not.
Start example by running `pup run` if pup is installed, or something like `deno run -A ../../../pup.ts run` if not.

Browse to <http://localhost:5000/>

Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/basic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ its logs to separate files.

`cd` to `/docs/src/examples/basic` directory.

Start example by running `pup foreground` if pup is installed, or something like `deno run -A ../../../pup.ts foreground` if not.
Start example by running `pup run` if pup is installed, or something like `deno run -A ../../../pup.ts run` if not.

Success!
2 changes: 1 addition & 1 deletion docs/src/examples/cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Detailed documentation available at [5. Scaling applications](https://hexagon.gi

`cd` to `/docs/src/examples/cluster` directory.

Run using command `pup foreground`
Run using command `pup run`

Browse to `http://localhost:3456`

Expand Down
4 changes: 2 additions & 2 deletions docs/src/examples/splunk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The example at [/docs/src/examples/splunk](https://github.com/Hexagon/pup/tree/m
output to Splunk using the splunk-hec plugin.

> **Note:** If you're connecting to a Splunk HEC server with a bad certificate, such as during testing, you'll need to start pup manually with the `--unsafely-ignore-certificate-errors` flag. The full
> command for this would be `deno run -Ar --unsafely-ignore-certificate-errors https://deno.land/x/pup/pup.ts foreground` { .note }
> command for this would be `deno run -Ar --unsafely-ignore-certificate-errors https://deno.land/x/pup/pup.ts run` { .note }
## Files

Expand All @@ -29,6 +29,6 @@ The HEC token can be configured in the `pup.jsonc` configuration file as shown i

`cd` to `/docs/src/examples/splunk` directory.

Start the example by running `pup foreground` if pup is installed, or something like `deno run -A ../../../pup.ts foreground` if not.
Start the example by running `pup run` if pup is installed, or something like `deno run -A ../../../pup.ts run` if not.

Success!
2 changes: 1 addition & 1 deletion docs/src/examples/telemetry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ telemetry.emit("another-process-id", "my-event", { data: { to: "send" } })

`cd` to `docs/examples/telemetry` directory.

Start example by running `pup foreground` if pup is installed, or something like `deno run -A ../../../pup.ts foreground` if not.
Start example by running `pup run` if pup is installed, or something like `deno run -A ../../../pup.ts run` if not.

Now open another terminal and issue `pup status`, a brief overview of current status is shown, including memory usage.

Expand Down
4 changes: 2 additions & 2 deletions docs/src/examples/watcher/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ current directory (configuration `watch: ["."]`).

`cd` to `/docs/src/examples/watcher` directory.

Start example by running `pup foreground` if pup is installed, pup will automatically pick up the configuration in`pup.jsonc`.
Start example by running `pup run` if pup is installed, pup will automatically pick up the configuration in`pup.jsonc`.

Run something like `deno run -A ../../../pup.ts foreground` if pup is not installed globally.
Run something like `deno run -A ../../../pup.ts run` if pup is not installed globally.

Success!
2 changes: 1 addition & 1 deletion docs/src/examples/worker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ process using a worker. The process has logging configurations to write logs to

`cd` to `/docs/src/examples/worker` directory.

Start example by running `pup foreground` if pup is installed, or something like `deno run -A ../../../pup.ts foreground` if not.
Start example by running `pup run` if pup is installed, or something like `deno run -A ../../../pup.ts run` if not.

Success!

Expand Down
4 changes: 2 additions & 2 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ simple instances running a single process:

`pup append --id "my-task" --cmd "deno run -A task.ts" --cron "0 0 * * * *"`

3. (Optional) Test run your instance (ecosystem):
3. (Optional) Test run your instance:

`pup foreground`
`pup run`

4. To make your instance run at boot, enable it using `pup enable-service`.

Expand Down
4 changes: 2 additions & 2 deletions docs/src/usage/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ To activate plugins, add your plugins to the configuration using this pattern:

## Validating the Configuration

To ensure your configuration is valid, just run `pup foreground` (or `pup run --config custom/path/to/config.json`). If using pup as a library, you can use the `validateConfiguration()` function
provided by the `/lib/core/configuration.ts` file. This function checks if the configuration adheres to the schema and will throw an error if it doesn't.
To ensure your configuration is valid, just run `pup run` (or `pup run --config custom/path/to/config.json`). If using pup as a library, you can use the `validateConfiguration()` function provided by
the `/lib/core/configuration.ts` file. This function checks if the configuration adheres to the schema and will throw an error if it doesn't.

With a valid configuration in place, you're ready to use Pup to manage your processes.

Expand Down
4 changes: 2 additions & 2 deletions docs/src/usage/service.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Follow the guide below to install Pup as a system service and launch at boot. Th

### Prerequisites

Ensure that you have a working environment set up so that you can run `pup foreground` with a `pup.json` in the current directory, or that you can start Pup using `pup run --config path/to/pup.json`.
Ensure that you have a working environment set up so that you can run `pup run` with a `pup.json` in the current directory, or that you can start Pup using `pup run --config path/to/pup.json`.

Now there is two options, User Mode Installation, or System Installation. User Mode Installation is recommended as it rhymes best with Deno, which is installed for the current user. User mode is only
supported with launchd or systemd.
Expand Down Expand Up @@ -144,7 +144,7 @@ Description=Pup
After=network.target

[Service]
ExecStart=/home/user/.deno/bin/deno run -A https://deno.land/x/pup/`pup.ts foreground` --config /path/to/your/pup.json
ExecStart=/home/user/.deno/bin/deno run -A https://deno.land/x/pup/`pup.ts run` --config /path/to/your/pup.json
Restart=always

[Install]
Expand Down
4 changes: 2 additions & 2 deletions lib/cli/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function checkArguments(args: ArgsParser): ArgsParser {
"restart",
"block",
"unblock",
"foreground",
"run",
"enable-service",
"disable-service",
"logs",
Expand Down Expand Up @@ -94,7 +94,7 @@ function checkArguments(args: ArgsParser): ArgsParser {

const hasDoubleDashCmd = args.hasRest()
const hasCmd = hasDoubleDashCmd || args.get("cmd") || args.get("worker")
const expectConfigOptions = baseArgument === "init" || baseArgument === "append" || (baseArgument === "foreground" && hasCmd)
const expectConfigOptions = baseArgument === "init" || baseArgument === "append" || (baseArgument === "run" && hasCmd)
const expectInstallerOptions = baseArgument === "setup" || baseArgument === "upgrade" || baseArgument === "update"

// Only one type of command can be present at the same time
Expand Down
8 changes: 4 additions & 4 deletions lib/cli/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ async function main() {
* - Find configuration using (--config)
* - Or generate configuration using (init)
*/
const runWithoutConfig = baseArgument == "foreground" && (cmd !== undefined || worker !== undefined)
const runWithoutConfig = baseArgument == "run" && (cmd !== undefined || worker !== undefined)
const useConfigFile = !runWithoutConfig
let configFile
if (useConfigFile) {
Expand All @@ -138,7 +138,7 @@ async function main() {
const name = parsedArgs.get("name") || "pup"
const config = parsedArgs.get("config")
const cwd = parsedArgs.get("cwd")
const cmd = `pup foreground ${config ? `--config ${config}` : ""}`
const cmd = `pup run ${config ? `--config ${config}` : ""}`
const user = parsedArgs.get("user")
const home = parsedArgs.get("home")
const env = parsedArgs.getArray("env") || []
Expand Down Expand Up @@ -436,8 +436,8 @@ async function main() {
/**
* Ready to start pup!
*/
if (baseArgument !== "foreground") {
console.error("Trying to start pup without 'foreground' argument, this should not happen. Exiting.")
if (baseArgument !== "run") {
console.error("Trying to start pup without 'run' argument, this should not happen. Exiting.")
exit(1)
}

Expand Down
2 changes: 1 addition & 1 deletion lib/cli/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function createFlagsMessage(externalInstaller: boolean): string {
{ separator: "empty" },
{ content: "Control and monitor instances", spanStart: 1 },
{ separator: "empty" },
{ long: "foreground", description: "Run a pup instance in foreground" },
{ long: "run", description: "Run a pup instance in run" },
{ long: "terminate", description: "Terminate pup instance using IPC" },
{ long: "status", description: "Show status for a pup instance" },
{ separator: "empty" },
Expand Down

0 comments on commit e0cbdd9

Please sign in to comment.