m28n

Registration

m28n is currently not available publicly.

Why not just rent servers from cloud provider X?

There are two major classes of cloud server providers:

We provide an server deployment solution that also takes care of autoscaling your servers and handling updates across your cluster. You provide us with API keys for the cloud providers you want to use (and we support), and we'll take care of managing them for you.

Usage

Create a file called m28n.json at the root directory of your project:
{
	// Project identifier
	"project": "my-project",
	
	// Identifier used for locating this project
	// This also creates a DNS record pointing to all servers at my-project-endpoint.r.n.m28.io
	// (useful for creating web servers, since the client can't use the sdk to find a server then)
	"endpoint": "my-project-endpoint",
		
	// What ports we want to health check to make sure this server is still up
	"httpHealthCheck": [ 80 ],
	
	// What to run once a server boots up
	"run": "node project.js",
	
	// Which files to send to servers
	"package": [
		"project.js",
	],
	
	// Where to create servers
	"regions": [
		"linode-fremont",
		"vultr-seattle"
	]
}
Our example node.js file project.js has the following content:
const http = require("http");

const server = http.createServer((req, res) => {
	res.statusCode = 200;
	res.setHeader('Content-Type', 'text/plain');
	res.end('Hello World\n');
});

server.listen(80);
Time to create servers for our project:
# Install the cli
npm install -g m28n-cli

# Your API token
export M28N_ACCOUNT_TOKEN=your_account_token

# Set up your API keys for the regions you want to use
m28n linode
m28n vultr

# Create the project
m28n create my-project

# Deploy! This is the only command you need to use afterwards
m28n deploy

# Want to rollback to a previous version?
# Stop the deploy and point clients back to the old servers
m28n rollback
Using the JavaScript SDK to grab a server IP:
<script src="https://c.n.m28.io/sdk.js"></script>
<script>
// The SDK is used to provide us load balanced servers in a smarter way
// than just round-robin dns

// This gives you one server per region, and it's up to you to pick one
m28n.findServers("my-project-endpoint", function(err, servers){
	if(err) throw err;
	console.log(servers); // =>
	// {
	//     "linode-fremont": {
	//         "id": "abc",
	//         "ipv4": "1.2.3.4",
	//         "ipv6": null
	//     },
	//     
	//     "vultr-seattle": {
	//         "id": "xyz",
	//         "ipv4": "4.3.2.1",
	//         "ipv6": null
	//     }
	// }
});

// If you want to do some transparent latency testing and get servers
// ordered by latency:
m28n.findServerPreference("my-project-endpoint", function(err, servers){
	if(err) throw err;
	console.log(servers); // =>
	// [
	//     {
	//         "id": "xyz",
	//         "ipv4": "4.3.2.1",
	//         "ipv6": null
	//     },
	//     
	//     {
	//         "id": "abc",
	//         "ipv4": "1.2.3.4",
	//         "ipv6": null
	//     }
	// ]
});
</script>
You can also use our DNS resolver to find a random server, but this won't do proper latency testing, so it should only be used for web servers and where you can't control how the client finds the server:
$ curl my-project-endpoint.r.m28n.net
Hello World

Documentation

cli

m28n # Prints help
m28n deploy # Deploys the current project
m28n status # Prints the status of the current project
m28n servers # Prints all servers associated with the current project
m28n env <env_json> # Sets the environment variables that all servers use (write-only, useful for storing tokens)
m28n create <identifier> # Creates a new project
m28n version # Prints the current deployed version
m28n rollback [version] # Rolls back the current version to another version, or to the previous version
m28n linode # Changes the linode API key associated with the account
m28n vultr # Changes the vultr API key associated with the account

References