- 1.0.3Latest
- 1.0.2
- 1.0.1
- 1.0.0
- 1.0.0-rc.45
- 1.0.0-rc.44
- 1.0.0-rc.43
- 1.0.0-rc.42
- 1.0.0-rc.41
- 1.0.0-rc.40
- 1.0.0-rc.39
- 1.0.0-rc.38
- 1.0.0-rc.37
- 1.0.0-rc.36
- 1.0.0-rc.35
- 1.0.0-rc.34
- 1.0.0-rc.33
- 1.0.0-rc.32
- 1.0.0-rc.31
- 1.0.0-rc.30
- 1.0.0-rc.29
- 1.0.0-rc.28
- 1.0.0-rc.27
- 1.0.0-rc.26
- 1.0.0-rc.25
- 1.0.0-rc.24
- 1.0.0-rc.23
- 1.0.0-rc.22
- 1.0.0-rc.21
- 1.0.0-rc.20
- 1.0.0-rc.19
- 1.0.0-rc.18
- 1.0.0-rc.17
- 1.0.0-rc.16
- 1.0.0-rc.15
- 1.0.0-rc.14
- 1.0.0-rc.13
- 1.0.0-rc.12
- 1.0.0-rc.11
- 1.0.0-rc.10
- 1.0.0-rc.9
- 1.0.0-rc.8
- 1.0.0-rc.7
- 1.0.0-rc.6
- 1.0.0-rc.5
- 1.0.0-rc.4
- 1.0.0-rc.3
- 1.0.0-rc.2
- 1.0.0-rc.1
- 1.0.0-rc.0
- 1.0.0-beta.37
- 1.0.0-beta.36
- 1.0.0-beta.35
- 1.0.0-beta.34
- 1.0.0-beta.33
- 1.0.0-beta.32
- 1.0.0-beta.31
- 1.0.0-beta.30
- 1.0.0-beta.29
- 1.0.0-beta.28
- 1.0.0-beta.27
- 1.0.0-beta.26
- 1.0.0-beta.25
- 1.0.0-beta.24
- 1.0.0-beta.23
- 1.0.0-beta.22
- 1.0.0-beta.21
- 1.0.0-beta.20
- 1.0.0-beta.19
- 1.0.0-beta.18
- 1.0.0-beta.17
- 1.0.0-beta.16
- 1.0.0-beta.15
- 1.0.0-beta.14
- 1.0.0-beta.13
- 1.0.0-beta.12
- 1.0.0-beta.11
- 1.0.0-beta.10
- 1.0.0-beta.9
- 1.0.0-beta.8
- 1.0.0-beta.7
- 1.0.0-beta.6
- 1.0.0-beta.5
- 1.0.0-beta.4
- 1.0.0-beta.3
- 1.0.0-beta.2
- 1.0.0-beta.1
- 1.0.0-beta.0
- 1.0.0-alpha-35
- 1.0.0-alpha-34
- 1.0.0-alpha-33
- 1.0.0-alpha-32
- 1.0.0-alpha-31
- 1.0.0-alpha-30
- 1.0.0-alpha-29
- 1.0.0-alpha-28
- 1.0.0-alpha-27
- 1.0.0-alpha-26
- 1.0.0-alpha-25
- 1.0.0-alpha-23
- 1.0.0-alpha-22
- 1.0.0-alpha-21
- 1.0.0-alpha-20
- 1.0.0-alpha-19
- 1.0.0-alpha-18
- 1.0.0-alpha-17
- 1.0.0-alpha-16
- 1.0.0-alpha-15
- 1.0.0-alpha-14
- 1.0.0-alpha-13
- 1.0.0-alpha-12
- 1.0.0-alpha-11
- 1.0.0-alpha-10
- 1.0.0-alpha-9
- 1.0.0-alpha-8
- 1.0.0-alpha-7
- 1.0.0-alpha-6
- 1.0.0-alpha-5
- 1.0.0-alpha-4
- 1.0.0-alpha-3
- 1.0.0-alpha-2
- 1.0.0-alpha-1
- 1.0.0-alpha.0
- 0.0.4
- 0.0.3
- 0.0.2
- 0.0.1-dev.0
Pup - Simple yet powerful Process Manager
Pup is a command-line tool that simplifies the management of processes. Pup can start, stop, restart, and keep processes alive, as well as schedule processes using a cron pattern. It does also manage the logs of each process, gathering them into a single stdout or file, making it easy to monitor and analyze the output of your processes in one place.
In addition to serving as a stand alone process manager, Pup can also function as a as a library, allowing you to seamlessly manage the internal process ecosystem of your application.
Pup revolves around a single configuration file, by default named āpup.jsoncā, which control every aspect of the processes to be executed, their execution methods, and the handling of logging.
Note Please note that Pup is currently in an early stage of development and may contain bugs or unexpected behavior. Use at your own risk.
Installation
Latest version of pup can be installed using Deno with the following command:
deno install -A -n pup https://deno.land/x/pup/pup.ts
The -A flag grants all permissions needed for Pup to work properly. In case of Deno subprocesses, you can specify individual permissions for each process with the usual command line flags.
Note Before using Pup, you need to have Deno installed on your system. You can download and install Deno with a single command following the instructions provided on the official website: https://deno.land/#installation
Upgrading from a previous version
Passing -fr
to the installation command will clear cache and upgrade pup to the latest version. -A
grants all permission for pup to work properly.
deno install -frA https://deno.land/x/pup/pup.ts
Usage
To start using Pup, you can simply run pup
on the command line. This will use the default configuration file pup.jsonc
located in the current directory.
If you want to use a different configuration file, you can pass the --config
flag followed by the filename:
pup --config myconfig.json
Once Pup is running, it will read the configuration file and start the processes defined in it. You can also use Pup as a library within a Deno program to manage child processes.
While running, pup will keep track of current state in the file myconfig.jsonc.status
. If you pass the flag --status
to pup, it will print a summary on the console.
pup --status
or pup --config myconfig.json --status
Configuration
Pup is centered around a single configuration file called pup.jsonc
. This file defines every aspect of the program, such as the processes to manage, how to start them, and when to restart them.
Hereās an example of a pup.jsonc
with all possible options defined:
{
// Global logger configuration, all options can be ovverridden per process
"logger": {
// Decorate console log entries?
"decorate": true, // default true
// Use colors in console?
"colors": true, // default true
// Decorate log file entries?
"decorateFiles": true, // default true
// Write logs to files, if stderr is undefined it will default to the stdout file
"stdout": "pup.log", // default undefined
"stderr": "pup.error.log" // default undefined or stdout, if defined
},
// Process configuration - Required to be an array, and at least one process definition is required
"processes": [
// One object per process ...
{
"name": "kept-alive-server", // Required
"cmd": ["deno", "run", "--allow-read", "./examples/basic/server.js"], // Required
"cwd": "/path/to/workingdir", // default undefined
"env": { // default undefined
"TZ": "Europe/Olso"
},
"autostart": true, // default undefined, process will not autostart by default
// "cron": "*/5 * * * * *", // default undefined
"restart": "always", // default undefined, possible values ["always" | "error" | undefined]
"maxRestarts": 10, // default undefined - restart infinitely'
"restartDelayMs": 10000 // default 10000
},
{
"name": "periodic-example-task",
"cmd": ["deno", "run", "--allow-read", "./examples/basic/task.js"],
"cron": "*/5 * * * * *", // default undefined
// Overrides to global logger
// Note: "colors" is not configurable per process
"logger": {
"console": true, // defaults to global configuration or true
"decorateFiles": true, // defaults to global configuration or false
"stdout": "periodic-example-task.log",
"stderr": "periodic-example-task.error.log"
}
}
]
}
In this example, we define a process called server-task
. We specify the command to start the process using an array of strings. We set it to start immediately, and to restart after 10 seconds after
quitting for whatever reason.
We also define a complementary process which is launched every 10 seconds using a cron pattern.
Full example available at /examples/basic
Running the example
Change working dir to the example directory containg a couple of scripts and pup.jsonc
cd /examples/basic
Start pup by running the command pup
. If you have not yet installed pup, you can run it from this repository like this.
deno run -A ../../pup.ts
server.js will start instantly, and will restart automatically 10 seconds after exiting. task.js will start every tenth second according to cron pattern */10 * * * * *
Output
Library usage
Import pup from your favorite cdn, we prefer deno.land/x/pup.
import { GlobalLoggerConfiguration, ProcessConfiguration, Pup } from "https://deno.land/x/pup/pup.ts"
const configuration = {
"logger": {
/* optional */
},
"processes": [
{/*...*/},
{/*...*/},
],
}
const pup = await new Pup(configuration /* OPTIONAL: , statusFile */)
// Go!
pup.start()
Custom logger
// Create a pup instance
const pup = new Pup() /* configuration */
// Create a custom logger
const logger = (severity: string, category: string, text: string, _config?: GlobalLoggerConfiguration, process?: ProcessConfiguration) => {
// Initiator
const initiator = process ? process.name : "core"
// Custom log function
console.log(`${initiator}(${severity}:${category}): ${text}`)
// Block built in logger by returning true
return true
}
// Attach the logger to pup
pup.logger.attach(logger)
pup.start()
Contributions
Contributions to Pup are very welcome! Please read CONTRIBUTING.md, fork the repository, make your changes, and submit a pull request. We appreciate all feedback and contributions that help make Pup better.