Skip to content

larvit/urltocmd

Repository files navigation

URL to Command

Run a command on a server based on an URL

Options

Takes environment variables:

PORT

defaults to 3000

LOGFILE

Set to have the log written to this path in addition to stdout

Using .env file

For simplicity, add these to the .env file. Like this:

.env
PORT=5400
LOGFILE=/var/log/urltocmd.log

How to run

The command takes a JSON as input and executes a web server based on the content.

The JSON must be structured as follows:

[
	{
		"url": "/some-url",
		"cmd": "command to be ran on the server"
	},
	{
		"url": "/some-other-url",
		"cmd": "Another command to be ran on the server"
	}
]

For example, it can be ran like this:

echo '[{"url":"/some-url","cmd":"do something"}]' | npm start

Or from a file:

cat urlsAndCmds.json | npm start

Releases

No releases published

Packages

No packages published