Motita

Updates and scheduled tasks

Stay on the newest verified release, and run tasks on a cadence.

Updating

  1. 1/updateFinds the newest release
  2. 2DownloadFrom the release itself
  3. 3CheckMust match SHA256SUMS
  4. 4InstallNothing is installed on a mismatch
  5. 5RestartA gateway started with -serve does it alone

/update installs the newest release. The welcome screen and the browser's sidebar tell you when one exists. The download must match the release's SHA256SUMS or nothing is installed. A gateway started with -serve restarts itself on the new binary; an interface tells you to restart it.

The gateway reports its own build through motita gateway status, so after installing over an old binary you can tell whether the process still running is the previous one.

Releases are cut automatically from semantic commits: feat bumps the minor version, fix the patch, and a breaking change the major. The newest version is always shown on the home page.

Scheduled tasks

A scheduled task is a task or a plan the gateway submits on its own, on a cadence, with nobody at the keyboard. Each one is a small JSON file in ~/.motita/schedules/ that you can read and edit by hand.

  1. 1The time comesevery 24h after the last run
  2. 2The gateway submits itAs a plan or a task, nobody at the keyboard
  3. 3It runsIn the session it is pinned to
  4. 4You see the resultIn the interface

The same call from code, in the most used languages (set MOTITA_TOKEN first):

# create a plan that runs every 24 hours
curl -s -X POST "http://127.0.0.1:7477/v1/schedules" \
  -H "Authorization: Bearer $MOTITA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"title":"nightly audit","task":"check the logs and report","kind":"plan","every":"24h"}'
const res = await fetch("http://127.0.0.1:7477/v1/schedules", {
  method: "POST",
  headers: {
    Authorization: "Bearer " + process.env.MOTITA_TOKEN, // the gateway token: motita gateway start -token-only
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    title: "nightly audit",
    task: "check the logs and report",
    kind: "plan", // create a plan that runs every 24 hours
    every: "24h",
  }),
});
console.log(await res.json()); // the schedule, as stored
import { env } from "node:process";

interface Schedule {
  title: string;
  task: string;
  kind: "plan" | "task";
  every: string;
}

const schedule: Schedule = {
  title: "nightly audit",
  task: "check the logs and report",
  kind: "plan", // create a plan that runs every 24 hours
  every: "24h",
};

const res = await fetch("http://127.0.0.1:7477/v1/schedules", {
  method: "POST",
  headers: {
    Authorization: "Bearer " + env.MOTITA_TOKEN, // the gateway token: motita gateway start -token-only
    "Content-Type": "application/json",
  },
  body: JSON.stringify(schedule),
});
console.log(await res.json()); // the schedule, as stored
# pip install requests
import os

import requests

res = requests.post(
    "http://127.0.0.1:7477/v1/schedules",
    headers={"Authorization": "Bearer " + os.environ["MOTITA_TOKEN"]},  # the gateway token: motita gateway start -token-only
    json={
        "title": "nightly audit",
        "task": "check the logs and report",
        "kind": "plan",  # create a plan that runs every 24 hours
        "every": "24h",
    },
)
print(res.json())  # the schedule, as stored
package main

import (
	"fmt"
	"io"
	"log"
	"net/http"
	"os"
	"strings"
)

func main() {
	body := strings.NewReader(
		`{"title":"nightly audit","task":"check the logs and report","kind":"plan","every":"24h"}`,
	) // create a plan that runs every 24 hours
	req, err := http.NewRequest(http.MethodPost, "http://127.0.0.1:7477/v1/schedules", body)
	if err != nil {
		log.Fatal(err)
	}
	req.Header.Set("Authorization", "Bearer "+os.Getenv("MOTITA_TOKEN")) // the gateway token: motita gateway start -token-only
	req.Header.Set("Content-Type", "application/json")

	res, err := http.DefaultClient.Do(req)
	if err != nil {
		log.Fatal(err)
	}
	defer res.Body.Close()
	out, _ := io.ReadAll(res.Body)
	fmt.Println(string(out)) // the schedule, as stored
}
// Cargo.toml: reqwest = { version = "0.12", features = ["blocking", "json"] }, serde_json = "1"
use serde_json::{json, Value};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let token = std::env::var("MOTITA_TOKEN")?; // the gateway token: motita gateway start -token-only
    let created: Value = reqwest::blocking::Client::new()
        .post("http://127.0.0.1:7477/v1/schedules")
        .bearer_auth(token)
        .json(&json!({
            "title": "nightly audit",
            "task": "check the logs and report",
            "kind": "plan", // create a plan that runs every 24 hours
            "every": "24h",
        }))
        .send()?
        .json()?;
    println!("{created}"); // the schedule, as stored
    Ok(())
}

Go deeper