From b8f1409b7d5652afdfba47215ac741d7d1d5dd17 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 6 Nov 2026 16:18:20 +0000 Subject: [PATCH 01/11] Move the dashboard into internal/dashboard The dashboard code moves out of cmd with no change in behavior: cmd/dash.go, lib/mcp_handler.go, lib/process_validator.go, the dash SysProcAttr helper, and the dash tests. - internal/dashboard imports cmd; cmd never imports the dashboard. cmd/dashboard_api.go exports the helpers the dashboard uses, and internal/dashboard/cli.go maps them to their old names so dash.go keeps its body. - main.go registers dash. A later change can build cronitor without the dashboard by dropping that import, and build crontab-dashboard as a second binary. - main_test.go checks that dash stays registered with its flags. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01B4Z4Doj15mT9bCnvdKp5UB --- cmd/dashboard_api.go | 60 +++++++++++++++++++ cmd/exec_unix.go | 7 --- cmd/exec_windows.go | 8 --- cmd/root.go | 1 + cmd/wrap_sync_test.go | 9 +++ internal/dashboard/cli.go | 52 ++++++++++++++++ {cmd => internal/dashboard}/dash.go | 13 ++-- .../dashboard}/dash_marker_unix_test.go | 2 +- {cmd => internal/dashboard}/dash_wrap_test.go | 2 +- .../dashboard}/dash_wrap_unix_test.go | 2 +- internal/dashboard/exec_unix.go | 12 ++++ internal/dashboard/exec_windows.go | 13 ++++ internal/dashboard/helpers_test.go | 32 ++++++++++ {lib => internal/dashboard}/mcp_handler.go | 2 +- .../dashboard}/process_validator.go | 2 +- main.go | 9 ++- main_test.go | 25 ++++++++ 17 files changed, 225 insertions(+), 26 deletions(-) create mode 100644 cmd/dashboard_api.go create mode 100644 internal/dashboard/cli.go rename {cmd => internal/dashboard}/dash.go (99%) rename {cmd => internal/dashboard}/dash_marker_unix_test.go (99%) rename {cmd => internal/dashboard}/dash_wrap_test.go (99%) rename {cmd => internal/dashboard}/dash_wrap_unix_test.go (99%) create mode 100644 internal/dashboard/exec_unix.go create mode 100644 internal/dashboard/exec_windows.go create mode 100644 internal/dashboard/helpers_test.go rename {lib => internal/dashboard}/mcp_handler.go (99%) rename {lib => internal/dashboard}/process_validator.go (99%) create mode 100644 main_test.go diff --git a/cmd/dashboard_api.go b/cmd/dashboard_api.go new file mode 100644 index 00000000..48ce2685 --- /dev/null +++ b/cmd/dashboard_api.go @@ -0,0 +1,60 @@ +package cmd + +import ( + "os" + "sync" + + "github.com/cronitorio/cronitor-cli/lib" +) + +// Exported for internal/dashboard, which builds on the CLI's configuration, +// API client, and telemetry. The dashboard imports cmd; cmd never imports the +// dashboard. + +var ( + VarApiKey = varApiKey + VarPingApiKey = varPingApiKey + VarEnv = varEnv + VarHostname = varHostname + VarLog = varLog + VarExcludeText = varExcludeText + VarDashUsername = varDashUsername + VarDashPassword = varDashPassword + VarAllowedIPs = varAllowedIPs + VarUsers = varUsers + VarMCPEnabled = varMCPEnabled +) + +func Log(msg string) { log(msg) } +func Fatal(msg string, exitCode int) { fatal(msg, exitCode) } +func CronitorApi() *lib.CronitorApi { return getCronitorApi() } +func ParseUsers() []string { return parseUsers() } +func ConfigFilePath() string { return configFilePath() } +func PersistConfigFile(path string, data []byte) error { return persistConfigFile(path, data) } +func MakeStamp() float64 { return makeStamp() } +func FormatStamp(timestamp float64) string { return formatStamp(timestamp) } +func GetFileSize(f *os.File) (int64, error) { return getFileSize(f) } +func MakeCronLikeEnv() []string { return makeCronLikeEnv() } +func OpenBrowser(url string) { openBrowser(url) } +func EffectiveHostname() string { return effectiveHostname() } +func CheckForUpdate() (*UpdateStatus, error) { return checkForUpdate() } +func PerformUpdate(status *UpdateStatus) error { return performUpdate(status) } + +func EffectiveTimezoneLocationName() lib.TimezoneLocationName { + return effectiveTimezoneLocationName() +} + +func CreateDefaultName(line *lib.Line, crontab *lib.Crontab, hostname string, excludeFromName []string, candidates map[string]bool) string { + return createDefaultName(line, crontab, hostname, excludeFromName, candidates) +} + +func SendPing(endpoint, uniqueIdentifier, message, series string, timestamp float64, duration *float64, exitCode *int, metrics map[string]int, schedule string, group *sync.WaitGroup) { + sendPing(endpoint, uniqueIdentifier, message, series, timestamp, duration, exitCode, metrics, schedule, group) +} + +func SaveSignupCredentials(apiKey, pingApiKey string) error { + return saveSignupCredentials(apiKey, pingApiKey) +} + +func FormatSignupPersistError(writeErr error) error { return formatSignupPersistError(writeErr) } +func SignupSuccessClientMessage() map[string]string { return signupSuccessClientMessage() } diff --git a/cmd/exec_unix.go b/cmd/exec_unix.go index ffc7912c..9ea2e345 100644 --- a/cmd/exec_unix.go +++ b/cmd/exec_unix.go @@ -11,10 +11,3 @@ func getPlatformSysProcAttr() *syscall.SysProcAttr { Setpgid: true, // Put child in its own process group } } - -// getPlatformSysProcAttrForDash returns platform-specific SysProcAttr configuration for dash command -func getPlatformSysProcAttrForDash() *syscall.SysProcAttr { - return &syscall.SysProcAttr{ - Setpgid: true, // Create a new process group for each "run now" command - } -} diff --git a/cmd/exec_windows.go b/cmd/exec_windows.go index 17c40d51..2caa538a 100644 --- a/cmd/exec_windows.go +++ b/cmd/exec_windows.go @@ -12,11 +12,3 @@ func getPlatformSysProcAttr() *syscall.SysProcAttr { // Process group functionality is handled differently on Windows } } - -// getPlatformSysProcAttrForDash returns platform-specific SysProcAttr configuration for dash command -func getPlatformSysProcAttrForDash() *syscall.SysProcAttr { - return &syscall.SysProcAttr{ - // Windows doesn't support Setpgid, so we return an empty SysProcAttr - // Process group functionality is handled differently on Windows - } -} diff --git a/cmd/root.go b/cmd/root.go index 3abb93fa..69fb326b 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -71,6 +71,7 @@ var varDashUsername = "CRONITOR_DASH_USER" var varDashPassword = "CRONITOR_DASH_PASS" var varAllowedIPs = "CRONITOR_ALLOWED_IPS" var varUsers = "CRONITOR_USERS" +var varMCPEnabled = "CRONITOR_MCP_ENABLED" var varApiVersion = "CRONITOR_API_VERSION" func init() { diff --git a/cmd/wrap_sync_test.go b/cmd/wrap_sync_test.go index 9a72ab55..290aa365 100644 --- a/cmd/wrap_sync_test.go +++ b/cmd/wrap_sync_test.go @@ -92,3 +92,12 @@ func withCronitorEnv(t *testing.T, env string) { viper.Set("CRONITOR_ENV", env) t.Cleanup(func() { viper.Set("CRONITOR_ENV", prev) }) } + +func readCrontab(t *testing.T, path string) string { + t.Helper() + b, err := os.ReadFile(path) + if err != nil { + t.Fatal(err) + } + return string(b) +} diff --git a/internal/dashboard/cli.go b/internal/dashboard/cli.go new file mode 100644 index 00000000..01923942 --- /dev/null +++ b/internal/dashboard/cli.go @@ -0,0 +1,52 @@ +package dashboard + +import "github.com/cronitorio/cronitor-cli/cmd" + +// The dashboard shares the CLI's configuration, API client, and telemetry. +// These names keep the dashboard code as it was when it lived in cmd. + +type ( + ConfigFile = cmd.ConfigFile + MCPInstanceConfig = cmd.MCPInstanceConfig + UpdateStatus = cmd.UpdateStatus +) + +// Version is the CLI release the dashboard is built with. +var Version = cmd.Version + +var ( + varApiKey = cmd.VarApiKey + varPingApiKey = cmd.VarPingApiKey + varEnv = cmd.VarEnv + varHostname = cmd.VarHostname + varLog = cmd.VarLog + varExcludeText = cmd.VarExcludeText + varDashUsername = cmd.VarDashUsername + varDashPassword = cmd.VarDashPassword + varAllowedIPs = cmd.VarAllowedIPs + varUsers = cmd.VarUsers + varMCPEnabled = cmd.VarMCPEnabled +) + +var ( + log = cmd.Log + fatal = cmd.Fatal + getCronitorApi = cmd.CronitorApi + sendPing = cmd.SendPing + parseUsers = cmd.ParseUsers + effectiveTimezoneLocationName = cmd.EffectiveTimezoneLocationName + effectiveHostname = cmd.EffectiveHostname + createDefaultName = cmd.CreateDefaultName + configFilePath = cmd.ConfigFilePath + persistConfigFile = cmd.PersistConfigFile + makeStamp = cmd.MakeStamp + formatStamp = cmd.FormatStamp + getFileSize = cmd.GetFileSize + makeCronLikeEnv = cmd.MakeCronLikeEnv + openBrowser = cmd.OpenBrowser + checkForUpdate = cmd.CheckForUpdate + performUpdate = cmd.PerformUpdate + saveSignupCredentials = cmd.SaveSignupCredentials + formatSignupPersistError = cmd.FormatSignupPersistError + signupSuccessClientMessage = cmd.SignupSuccessClientMessage +) diff --git a/cmd/dash.go b/internal/dashboard/dash.go similarity index 99% rename from cmd/dash.go rename to internal/dashboard/dash.go index a6e2b989..c4b2f237 100644 --- a/cmd/dash.go +++ b/internal/dashboard/dash.go @@ -1,4 +1,4 @@ -package cmd +package dashboard import ( "bufio" @@ -577,7 +577,6 @@ var cronCache = &crontabCache{} // Add new configuration variables const ( - varMCPEnabled = "CRONITOR_MCP_ENABLED" varMCPMode = "CRONITOR_MCP_MODE" varMCPInstance = "CRONITOR_MCP_INSTANCE" ) @@ -1020,7 +1019,7 @@ func runMCPServer(instanceName string) { ) // Create and register the Cronitor MCP handler - handler := lib.NewCronitorMCPHandler(instanceName) + handler := NewCronitorMCPHandler(instanceName) // Register tools if err := handler.RegisterTools(s); err != nil { @@ -1076,8 +1075,12 @@ func addLineToCrontab(file string, line string) error { return nil } +// Register adds the dash command to a root command. +func Register(root *cobra.Command) { + root.AddCommand(dashCmd) +} + func init() { - RootCmd.AddCommand(dashCmd) dashCmd.Flags().Int("port", 9000, "Port to run the dashboard on") dashCmd.Flags().Bool("safe-mode", false, "Limit the ability to edit jobs, crontabs, and settings") dashCmd.Flags().Bool("mcp", false, "Enable MCP server mode for Cursor integration (deprecated: use --mcp-instance instead)") @@ -2076,7 +2079,7 @@ func handleKillInstances(w http.ResponseWriter, r *http.Request) { var killed []int // Create process validator for comprehensive PID validation - processValidator := lib.NewProcessValidator() + processValidator := NewProcessValidator() for _, pid := range request.PIDs { // Perform comprehensive PID validation including ownership checks diff --git a/cmd/dash_marker_unix_test.go b/internal/dashboard/dash_marker_unix_test.go similarity index 99% rename from cmd/dash_marker_unix_test.go rename to internal/dashboard/dash_marker_unix_test.go index b30c2fbc..e551c6ff 100644 --- a/cmd/dash_marker_unix_test.go +++ b/internal/dashboard/dash_marker_unix_test.go @@ -1,6 +1,6 @@ //go:build !windows -package cmd +package dashboard import ( "encoding/json" diff --git a/cmd/dash_wrap_test.go b/internal/dashboard/dash_wrap_test.go similarity index 99% rename from cmd/dash_wrap_test.go rename to internal/dashboard/dash_wrap_test.go index 90db589b..9d4603bb 100644 --- a/cmd/dash_wrap_test.go +++ b/internal/dashboard/dash_wrap_test.go @@ -1,4 +1,4 @@ -package cmd +package dashboard import ( "encoding/json" diff --git a/cmd/dash_wrap_unix_test.go b/internal/dashboard/dash_wrap_unix_test.go similarity index 99% rename from cmd/dash_wrap_unix_test.go rename to internal/dashboard/dash_wrap_unix_test.go index 9a36b913..faa1bea2 100644 --- a/cmd/dash_wrap_unix_test.go +++ b/internal/dashboard/dash_wrap_unix_test.go @@ -1,6 +1,6 @@ //go:build !windows -package cmd +package dashboard import ( "encoding/json" diff --git a/internal/dashboard/exec_unix.go b/internal/dashboard/exec_unix.go new file mode 100644 index 00000000..607771e9 --- /dev/null +++ b/internal/dashboard/exec_unix.go @@ -0,0 +1,12 @@ +//go:build !windows + +package dashboard + +import "syscall" + +// getPlatformSysProcAttrForDash returns platform-specific SysProcAttr configuration for dash command +func getPlatformSysProcAttrForDash() *syscall.SysProcAttr { + return &syscall.SysProcAttr{ + Setpgid: true, // Create a new process group for each "run now" command + } +} diff --git a/internal/dashboard/exec_windows.go b/internal/dashboard/exec_windows.go new file mode 100644 index 00000000..cca98a42 --- /dev/null +++ b/internal/dashboard/exec_windows.go @@ -0,0 +1,13 @@ +//go:build windows + +package dashboard + +import "syscall" + +// getPlatformSysProcAttrForDash returns platform-specific SysProcAttr configuration for dash command +func getPlatformSysProcAttrForDash() *syscall.SysProcAttr { + return &syscall.SysProcAttr{ + // Windows doesn't support Setpgid, so we return an empty SysProcAttr + // Process group functionality is handled differently on Windows + } +} diff --git a/internal/dashboard/helpers_test.go b/internal/dashboard/helpers_test.go new file mode 100644 index 00000000..313b1123 --- /dev/null +++ b/internal/dashboard/helpers_test.go @@ -0,0 +1,32 @@ +package dashboard + +import ( + "testing" + + "github.com/cronitorio/cronitor-cli/lib" + "github.com/spf13/viper" +) + +// setupIntegrationTest points the API client at a mock server and returns a +// function that restores the previous state. +func setupIntegrationTest(mockURL string) func() { + oldBaseURL := lib.BaseURLOverride + oldAPIKey := viper.GetString("CRONITOR_API_KEY") + + lib.BaseURLOverride = mockURL + viper.Set("CRONITOR_API_KEY", "test-api-key-1234567890") + viper.Set("CRONITOR_API_VERSION", "") + + return func() { + lib.BaseURLOverride = oldBaseURL + viper.Set("CRONITOR_API_KEY", oldAPIKey) + viper.Set("CRONITOR_API_VERSION", "") + } +} + +func withCronitorEnv(t *testing.T, env string) { + t.Helper() + prev := viper.GetString("CRONITOR_ENV") + viper.Set("CRONITOR_ENV", env) + t.Cleanup(func() { viper.Set("CRONITOR_ENV", prev) }) +} diff --git a/lib/mcp_handler.go b/internal/dashboard/mcp_handler.go similarity index 99% rename from lib/mcp_handler.go rename to internal/dashboard/mcp_handler.go index c897c96e..f8ae845f 100644 --- a/lib/mcp_handler.go +++ b/internal/dashboard/mcp_handler.go @@ -1,4 +1,4 @@ -package lib +package dashboard import ( "bytes" diff --git a/lib/process_validator.go b/internal/dashboard/process_validator.go similarity index 99% rename from lib/process_validator.go rename to internal/dashboard/process_validator.go index eacb50aa..b81b8027 100644 --- a/lib/process_validator.go +++ b/internal/dashboard/process_validator.go @@ -1,4 +1,4 @@ -package lib +package dashboard import ( "fmt" diff --git a/main.go b/main.go index 9eb9bcc5..0316af5a 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "os" "github.com/cronitorio/cronitor-cli/cmd" + "github.com/cronitorio/cronitor-cli/internal/dashboard" ) //go:embed web/static @@ -37,6 +38,12 @@ func main() { os.Args[commandIndex] = "--" } - cmd.SetWebAssets(WebAssets) + registerCommands() cmd.Execute() } + +// registerCommands adds commands that live outside the cmd package. +func registerCommands() { + dashboard.SetWebAssets(WebAssets) + dashboard.Register(cmd.RootCmd) +} diff --git a/main_test.go b/main_test.go new file mode 100644 index 00000000..88c0542c --- /dev/null +++ b/main_test.go @@ -0,0 +1,25 @@ +package main + +import ( + "testing" + + "github.com/cronitorio/cronitor-cli/cmd" +) + +// The dashboard must stay registered on the CLI while its code lives in its +// own package. +func TestDashCommandIsRegistered(t *testing.T) { + registerCommands() + found, _, err := cmd.RootCmd.Find([]string{"dash"}) + if err != nil { + t.Fatal(err) + } + if found.Name() != "dash" { + t.Fatalf("found %q, want dash", found.Name()) + } + for _, flag := range []string{"port", "mcp-instance"} { + if found.Flags().Lookup(flag) == nil { + t.Errorf("dash is missing --%s", flag) + } + } +} From ee1b0a63efce65f86ae4d72d71ea6ac9045d88a6 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 6 Nov 2026 16:24:24 +0000 Subject: [PATCH 02/11] Add the crontab-dashboard binary cmd/crontab-dashboard builds the dashboard as its own program from the same commit as cronitor. It runs the dash command, so `crontab-dashboard --port 9100` behaves like `cronitor dash --port 9100` and accepts the same root flags. - The frontend is embedded by a new web package. web/static/README.md is committed so Go builds and tests without Node; the npm build keeps it. - cronitor still includes the dashboard; a later commit removes it. - The systemd restart lookup still finds cronitor-dashboard.service when the running binary is crontab-dashboard. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01B4Z4Doj15mT9bCnvdKp5UB --- .gitignore | 3 ++- cmd/crontab-dashboard/main.go | 30 ++++++++++++++++++++++++++ cmd/crontab-dashboard/main_test.go | 34 ++++++++++++++++++++++++++++++ internal/dashboard/dash.go | 34 ++++++++++++++---------------- internal/dashboard/restart_test.go | 17 +++++++++++++++ main.go | 5 ----- web/assets.go | 8 +++++++ web/scripts/build.js | 11 +++++++++- web/static/README.md | 3 +++ 9 files changed, 120 insertions(+), 25 deletions(-) create mode 100644 cmd/crontab-dashboard/main.go create mode 100644 cmd/crontab-dashboard/main_test.go create mode 100644 internal/dashboard/restart_test.go create mode 100644 web/assets.go create mode 100644 web/static/README.md diff --git a/.gitignore b/.gitignore index e23adefb..bd8d1d71 100644 --- a/.gitignore +++ b/.gitignore @@ -79,7 +79,8 @@ TODO.md # Dashboard node_modules/ -web/static/ +web/static/* +!web/static/README.md cronitor-linux Claude.md diff --git a/cmd/crontab-dashboard/main.go b/cmd/crontab-dashboard/main.go new file mode 100644 index 00000000..fde5e873 --- /dev/null +++ b/cmd/crontab-dashboard/main.go @@ -0,0 +1,30 @@ +// crontab-dashboard is the Crontab Guru Dashboard. It is built from the same +// commit as cronitor and shares its configuration, flags, and API client. +package main + +import ( + "os" + + "github.com/cronitorio/cronitor-cli/cmd" + "github.com/cronitorio/cronitor-cli/internal/dashboard" +) + +func main() { + setup() + os.Args = dashboardArgs(os.Args) + cmd.Execute() +} + +func setup() { + cmd.RootCmd.Use = "crontab-dashboard" + dashboard.Register(cmd.RootCmd) +} + +// dashboardArgs runs the dash command unless it is already named, so +// `crontab-dashboard --port 9100` and `cronitor dash --port 9100` match. +func dashboardArgs(args []string) []string { + if len(args) > 1 && args[1] == "dash" { + return args + } + return append([]string{args[0], "dash"}, args[1:]...) +} diff --git a/cmd/crontab-dashboard/main_test.go b/cmd/crontab-dashboard/main_test.go new file mode 100644 index 00000000..4dd3f46d --- /dev/null +++ b/cmd/crontab-dashboard/main_test.go @@ -0,0 +1,34 @@ +package main + +import ( + "reflect" + "testing" + + "github.com/cronitorio/cronitor-cli/cmd" +) + +func TestDashboardArgsRunDash(t *testing.T) { + for _, tc := range []struct{ in, want []string }{ + {[]string{"crontab-dashboard"}, []string{"crontab-dashboard", "dash"}}, + {[]string{"crontab-dashboard", "--port", "9100"}, []string{"crontab-dashboard", "dash", "--port", "9100"}}, + {[]string{"crontab-dashboard", "dash", "--safe-mode"}, []string{"crontab-dashboard", "dash", "--safe-mode"}}, + } { + if got := dashboardArgs(tc.in); !reflect.DeepEqual(got, tc.want) { + t.Errorf("dashboardArgs(%q) = %q, want %q", tc.in, got, tc.want) + } + } +} + +func TestDashboardRegistersDash(t *testing.T) { + setup() + found, _, err := cmd.RootCmd.Find([]string{"dash"}) + if err != nil || found.Name() != "dash" { + t.Fatalf("dash not registered: %v", err) + } + if found.Flags().Lookup("port") == nil { + t.Fatal("dash is missing --port") + } + if cmd.RootCmd.Use != "crontab-dashboard" { + t.Errorf("root Use = %q", cmd.RootCmd.Use) + } +} diff --git a/internal/dashboard/dash.go b/internal/dashboard/dash.go index c4b2f237..a1994efd 100644 --- a/internal/dashboard/dash.go +++ b/internal/dashboard/dash.go @@ -5,7 +5,6 @@ import ( "bytes" "context" "crypto/rand" - "embed" "encoding/base64" "encoding/hex" "encoding/json" @@ -30,18 +29,13 @@ import ( "time" "github.com/cronitorio/cronitor-cli/lib" + "github.com/cronitorio/cronitor-cli/web" "github.com/mark3labs/mcp-go/server" "github.com/spf13/cobra" "github.com/spf13/viper" "golang.org/x/time/rate" ) -var webAssets embed.FS - -func SetWebAssets(assets embed.FS) { - webAssets = assets -} - // IP Filter for restricting access by IP address type IPFilter struct { allowedNetworks []*net.IPNet @@ -859,7 +853,7 @@ not start a web server but instead communicates via stdio protocol.`, } // Get the embedded filesystem - fsys, err := fs.Sub(webAssets, "web/static") + fsys, err := fs.Sub(web.Static, "static") if err != nil { fatal(err.Error(), 1) } @@ -3096,17 +3090,8 @@ func getSystemdServiceName() string { baseName := strings.TrimSuffix(filepath.Base(executable), filepath.Ext(executable)) - // Common patterns for systemd service names - possibleNames := []string{ - baseName + ".service", - baseName + "-dashboard.service", - "crontab-guru-dashboard.service", // User mentioned this specific name - "cronitor-cli.service", - "cronitor.service", - } - // Check which service exists and is active - for _, name := range possibleNames { + for _, name := range systemdServiceCandidates(baseName) { cmd := exec.Command("systemctl", "is-active", "--quiet", name) if err := cmd.Run(); err == nil { return name @@ -3116,6 +3101,19 @@ func getSystemdServiceName() string { return "" } +// systemdServiceCandidates lists common unit names for the dashboard. Units +// written for `cronitor dash` keep working after the move to crontab-dashboard. +func systemdServiceCandidates(baseName string) []string { + return []string{ + baseName + ".service", + "crontab-dashboard.service", + "cronitor-dashboard.service", + "crontab-guru-dashboard.service", + "cronitor-cli.service", + "cronitor.service", + } +} + // performManualRestart performs a manual restart (non-systemd) func performManualRestart(sendProgress func(string)) error { // Get current executable path and arguments diff --git a/internal/dashboard/restart_test.go b/internal/dashboard/restart_test.go new file mode 100644 index 00000000..6397584d --- /dev/null +++ b/internal/dashboard/restart_test.go @@ -0,0 +1,17 @@ +package dashboard + +import "testing" + +// Units written for `cronitor dash` must still be found when the running +// binary is crontab-dashboard. +func TestSystemdServiceCandidatesKeepCronitorNames(t *testing.T) { + got := map[string]bool{} + for _, name := range systemdServiceCandidates("crontab-dashboard") { + got[name] = true + } + for _, want := range []string{"crontab-dashboard.service", "cronitor-dashboard.service", "cronitor.service", "crontab-guru-dashboard.service"} { + if !got[want] { + t.Errorf("missing %s", want) + } + } +} diff --git a/main.go b/main.go index 0316af5a..cad61d10 100644 --- a/main.go +++ b/main.go @@ -1,16 +1,12 @@ package main import ( - "embed" "os" "github.com/cronitorio/cronitor-cli/cmd" "github.com/cronitorio/cronitor-cli/internal/dashboard" ) -//go:embed web/static -var WebAssets embed.FS - func main() { // Ensure that flags on `exec` commands are not parsed by Cobra // Inject a `--` param @@ -44,6 +40,5 @@ func main() { // registerCommands adds commands that live outside the cmd package. func registerCommands() { - dashboard.SetWebAssets(WebAssets) dashboard.Register(cmd.RootCmd) } diff --git a/web/assets.go b/web/assets.go new file mode 100644 index 00000000..c2562a7e --- /dev/null +++ b/web/assets.go @@ -0,0 +1,8 @@ +// Package web holds the dashboard's built frontend. Run `npm run build` in +// this folder to write web/static before building crontab-dashboard. +package web + +import "embed" + +//go:embed static +var Static embed.FS diff --git a/web/scripts/build.js b/web/scripts/build.js index b67b7ba9..8ef2d469 100644 --- a/web/scripts/build.js +++ b/web/scripts/build.js @@ -44,7 +44,16 @@ console.log('Starting build process...'); const staticDir = path.join(__dirname, '..', 'static'); if (fs.existsSync(staticDir)) { console.log('Cleaning static directory...'); - removeDir(staticDir); + // Keep the committed placeholder; see web/assets.go. + fs.readdirSync(staticDir).forEach((file) => { + if (file === 'README.md') return; + const curPath = path.join(staticDir, file); + if (fs.lstatSync(curPath).isDirectory()) { + removeDir(curPath); + } else { + fs.unlinkSync(curPath); + } + }); } // Create static directory diff --git a/web/static/README.md b/web/static/README.md new file mode 100644 index 00000000..89fa42bd --- /dev/null +++ b/web/static/README.md @@ -0,0 +1,3 @@ +`npm run build` writes the dashboard frontend here. Go embeds this folder +into `crontab-dashboard` (see `web/assets.go`). This file is committed so Go +can build and test without Node; a build without the frontend serves no UI. From a72e82c2c1a1eb031b1ea73ec86363ecac5de4cb Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 6 Nov 2026 16:26:06 +0000 Subject: [PATCH 03/11] Update cronitor and crontab-dashboard together Each release has _ archives for cronitor and crontab-dashboard__ archives for the dashboard. The updater now picks the asset for the running program, then updates the other program when it is in the same folder, so both stay at one version. - `cronitor update` updates a crontab-dashboard next to it and says so. - The dashboard's update button updates itself and the cronitor next to it. Before, it would have installed the cronitor archive over the dashboard. - The cronitor archive keeps its name, so older `cronitor update` versions keep working. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01B4Z4Doj15mT9bCnvdKp5UB --- cmd/crontab-dashboard/main.go | 3 +- cmd/crontab-dashboard/main_test.go | 3 + cmd/update.go | 110 ++++++++++++++---- cmd/update_test.go | 175 +++++++++++++++++++++++++++++ 4 files changed, 271 insertions(+), 20 deletions(-) create mode 100644 cmd/update_test.go diff --git a/cmd/crontab-dashboard/main.go b/cmd/crontab-dashboard/main.go index fde5e873..44602af4 100644 --- a/cmd/crontab-dashboard/main.go +++ b/cmd/crontab-dashboard/main.go @@ -16,7 +16,8 @@ func main() { } func setup() { - cmd.RootCmd.Use = "crontab-dashboard" + cmd.RootCmd.Use = cmd.DashboardBinaryName + cmd.SetUpdateBinary(cmd.DashboardBinaryName) dashboard.Register(cmd.RootCmd) } diff --git a/cmd/crontab-dashboard/main_test.go b/cmd/crontab-dashboard/main_test.go index 4dd3f46d..9911666f 100644 --- a/cmd/crontab-dashboard/main_test.go +++ b/cmd/crontab-dashboard/main_test.go @@ -28,6 +28,9 @@ func TestDashboardRegistersDash(t *testing.T) { if found.Flags().Lookup("port") == nil { t.Fatal("dash is missing --port") } + if cmd.UpdateBinary() != cmd.DashboardBinaryName { + t.Errorf("updater binary = %q", cmd.UpdateBinary()) + } if cmd.RootCmd.Use != "crontab-dashboard" { t.Errorf("root Use = %q", cmd.RootCmd.Use) } diff --git a/cmd/update.go b/cmd/update.go index 6d78a7e7..79dc5d44 100644 --- a/cmd/update.go +++ b/cmd/update.go @@ -8,6 +8,7 @@ import ( "net/http" "os" "os/exec" + "path/filepath" "runtime" "strconv" "strings" @@ -42,6 +43,57 @@ const ( checksumExtension = ".sha256" ) +// DashboardBinaryName is the dashboard executable. Each release has +// _ assets for cronitor and crontab-dashboard__ assets +// for the dashboard. +const DashboardBinaryName = "crontab-dashboard" + +var releaseURL = "https://api.github.com/repos/cronitorio/cronitor-cli/releases/latest" + +// updateBinary is the program running: cronitor or the dashboard. +var updateBinary = "cronitor" + +// SetUpdateBinary tells the updater which program is running. +func SetUpdateBinary(name string) { updateBinary = name } + +// UpdateBinary returns the program the updater replaces first. +func UpdateBinary() string { return updateBinary } + +var executablePath = func() (string, error) { + executable, err := os.Executable() + if err != nil { + return "", err + } + return filepath.EvalSymlinks(executable) +} + +// findAsset returns the release archive for a binary and platform. +func findAsset(release *GithubRelease, binary, goos, goarch string) (string, string) { + prefix := goos + "_" + goarch + "." + if binary == DashboardBinaryName { + prefix = DashboardBinaryName + "_" + prefix + } + for _, asset := range release.Assets { + if strings.HasPrefix(asset.Name, prefix) && !strings.HasSuffix(asset.Name, checksumExtension) && !strings.HasSuffix(asset.Name, ".md5") { + return asset.Name, asset.BrowserDownloadURL + } + } + return "", "" +} + +// siblingBinary returns the other program and its path next to executable. +func siblingBinary(executable string) (string, string) { + other := DashboardBinaryName + if updateBinary == DashboardBinaryName { + other = "cronitor" + } + name := other + if runtime.GOOS == "windows" { + name += ".exe" + } + return other, filepath.Join(filepath.Dir(executable), name) +} + var updateCmd = &cobra.Command{ Use: "update", Short: "Update to the latest version", @@ -70,6 +122,11 @@ func runUpdate(cmd *cobra.Command, args []string) { } fmt.Printf("Update complete! You are now on version %s\n", status.LatestVersion) + if executable, err := executablePath(); err == nil { + if other, sibling := siblingBinary(executable); fileExists(sibling) { + fmt.Printf("Also updated %s in %s\n", other, filepath.Dir(sibling)) + } + } } // checkForUpdate checks if a new version is available @@ -91,15 +148,7 @@ func checkForUpdate() (*UpdateStatus, error) { status.HasUpdate = isNewer(latestVersion, currentVersion) if status.HasUpdate { - // Find the appropriate asset for current platform - expectedName := fmt.Sprintf("%s_%s", runtime.GOOS, runtime.GOARCH) - for _, asset := range release.Assets { - if strings.HasPrefix(asset.Name, expectedName) && !strings.HasSuffix(asset.Name, checksumExtension) { - status.DownloadURL = asset.BrowserDownloadURL - status.AssetName = asset.Name - break - } - } + status.AssetName, status.DownloadURL = findAsset(release, updateBinary, runtime.GOOS, runtime.GOARCH) if status.DownloadURL == "" { err := fmt.Errorf("no release found for %s/%s", runtime.GOOS, runtime.GOARCH) @@ -111,7 +160,8 @@ func checkForUpdate() (*UpdateStatus, error) { return status, nil } -// performUpdate downloads and installs the update +// performUpdate installs the update, and updates the other program too when +// it is installed in the same folder so both stay at the same version. func performUpdate(status *UpdateStatus) error { if !status.HasUpdate { return fmt.Errorf("no update available") @@ -123,21 +173,38 @@ func performUpdate(status *UpdateStatus) error { return err } - // Get checksum - checksum, err := downloadChecksum(release, status.AssetName+checksumExtension) + executable, err := executablePath() if err != nil { - return fmt.Errorf("error downloading checksum: %v", err) + return fmt.Errorf("error getting executable path: %v", err) + } + if err := updateExecutable(release, executable, status.AssetName, status.DownloadURL); err != nil { + return err } - // Get current executable path - executable, err := os.Executable() + other, sibling := siblingBinary(executable) + if !fileExists(sibling) { + return nil + } + name, url := findAsset(release, other, runtime.GOOS, runtime.GOARCH) + if name == "" { + return fmt.Errorf("updated %s, but the release has no %s for %s/%s", filepath.Base(executable), other, runtime.GOOS, runtime.GOARCH) + } + if err := updateExecutable(release, sibling, name, url); err != nil { + return fmt.Errorf("updated %s, but not %s: %v", filepath.Base(executable), other, err) + } + return nil +} + +// updateExecutable replaces executable with the binary in a release asset. +func updateExecutable(release *GithubRelease, executable, assetName, downloadURL string) error { + checksum, err := downloadChecksum(release, assetName+checksumExtension) if err != nil { - return fmt.Errorf("error getting executable path: %v", err) + return fmt.Errorf("error downloading checksum: %v", err) } // Download and verify binary tmpFile := executable + ".new" - if err := downloadAndVerifyFile(status.DownloadURL, tmpFile, strings.TrimSpace(string(checksum))); err != nil { + if err := downloadAndVerifyFile(downloadURL, tmpFile, strings.TrimSpace(string(checksum))); err != nil { os.Remove(tmpFile) return fmt.Errorf("error downloading update: %v", err) } @@ -148,7 +215,7 @@ func performUpdate(status *UpdateStatus) error { return fmt.Errorf("error setting permissions: %v", err) } - // Test that the new binary is executable by running it with --version + // Test that the new binary is executable by running it with --help execCmd := exec.Command(tmpFile, "--help") if err := execCmd.Run(); err != nil { os.Remove(tmpFile) // Clean up @@ -185,7 +252,7 @@ func replaceExecutable(currentPath, newPath string) error { } func getLatestRelease() (*GithubRelease, error) { - resp, err := http.Get("https://api.github.com/repos/cronitorio/cronitor-cli/releases/latest") + resp, err := http.Get(releaseURL) if err != nil { return nil, err } @@ -297,3 +364,8 @@ func isNewer(latest, current string) bool { // If major versions are equal, compare minor versions return latestMinor > currentMinor } + +func fileExists(path string) bool { + info, err := os.Stat(path) + return err == nil && !info.IsDir() +} diff --git a/cmd/update_test.go b/cmd/update_test.go new file mode 100644 index 00000000..5ab3967d --- /dev/null +++ b/cmd/update_test.go @@ -0,0 +1,175 @@ +package cmd + +import ( + "archive/tar" + "bytes" + "compress/gzip" + "crypto/sha256" + "encoding/hex" + "encoding/json" + "net/http" + "net/http/httptest" + "os" + "path/filepath" + "runtime" + "strings" + "testing" +) + +func TestFindAssetPicksEachBinary(t *testing.T) { + release := &GithubRelease{} + for _, name := range []string{ + "crontab-dashboard_linux_amd64.tar.gz", "crontab-dashboard_linux_amd64.tar.gz.sha256", + "linux_amd64.tar.gz.md5", "linux_amd64.tar.gz", "linux_amd64.tar.gz.sha256", + "linux_arm64.tar.gz", + } { + release.Assets = append(release.Assets, struct { + Name string `json:"name"` + BrowserDownloadURL string `json:"browser_download_url"` + }{name, "https://example.test/" + name}) + } + if got, _ := findAsset(release, "cronitor", "linux", "amd64"); got != "linux_amd64.tar.gz" { + t.Errorf("cronitor asset = %q", got) + } + if got, _ := findAsset(release, DashboardBinaryName, "linux", "amd64"); got != "crontab-dashboard_linux_amd64.tar.gz" { + t.Errorf("dashboard asset = %q", got) + } + if got, _ := findAsset(release, DashboardBinaryName, "linux", "arm64"); got != "" { + t.Errorf("missing dashboard asset matched %q", got) + } +} + +// fakeRelease serves a GitHub release whose binaries are shell scripts that +// print which binary they are. +func fakeRelease(t *testing.T) { + t.Helper() + platform := runtime.GOOS + "_" + runtime.GOARCH + files := map[string][]byte{} + for asset, body := range map[string]string{ + platform + ".tar.gz": "new cronitor", + "crontab-dashboard_" + platform + ".tar.gz": "new dashboard", + } { + archive := tarGz(t, "#!/bin/sh\n# "+body+"\nexit 0\n") + sum := sha256.Sum256(archive) + files[asset] = archive + files[asset+".sha256"] = []byte(hex.EncodeToString(sum[:]) + "\n") + } + var server *httptest.Server + server = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.URL.Path == "/latest" { + release := GithubRelease{TagName: "999.0"} + for name := range files { + release.Assets = append(release.Assets, struct { + Name string `json:"name"` + BrowserDownloadURL string `json:"browser_download_url"` + }{name, server.URL + "/" + name}) + } + json.NewEncoder(w).Encode(release) + return + } + body, ok := files[strings.TrimPrefix(r.URL.Path, "/")] + if !ok { + http.NotFound(w, r) + return + } + w.Write(body) + })) + t.Cleanup(server.Close) + oldURL := releaseURL + releaseURL = server.URL + "/latest" + t.Cleanup(func() { releaseURL = oldURL }) +} + +func tarGz(t *testing.T, script string) []byte { + t.Helper() + var buf bytes.Buffer + gz := gzip.NewWriter(&buf) + tw := tar.NewWriter(gz) + tw.WriteHeader(&tar.Header{Name: "bin", Mode: 0755, Size: int64(len(script))}) + tw.Write([]byte(script)) + tw.Close() + gz.Close() + return buf.Bytes() +} + +func installFake(t *testing.T, dir, name string) string { + t.Helper() + path := filepath.Join(dir, name) + if err := os.WriteFile(path, []byte("#!/bin/sh\n# old\nexit 0\n"), 0755); err != nil { + t.Fatal(err) + } + return path +} + +func useExecutable(t *testing.T, path, binary string) { + t.Helper() + oldPath, oldBinary := executablePath, updateBinary + executablePath = func() (string, error) { return path, nil } + updateBinary = binary + t.Cleanup(func() { executablePath, updateBinary = oldPath, oldBinary }) +} + +func assertContains(t *testing.T, path, want string) { + t.Helper() + b, err := os.ReadFile(path) + if err != nil { + t.Fatal(err) + } + if !strings.Contains(string(b), want) { + t.Errorf("%s = %q, want %q", filepath.Base(path), b, want) + } +} + +func runFakeUpdate(t *testing.T) { + t.Helper() + status, err := checkForUpdate() + if err != nil { + t.Fatal(err) + } + if err := performUpdate(status); err != nil { + t.Fatal(err) + } +} + +func TestCronitorUpdateAlsoUpdatesDashboard(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("shell script fixtures") + } + fakeRelease(t) + dir := t.TempDir() + cli := installFake(t, dir, "cronitor") + dash := installFake(t, dir, DashboardBinaryName) + useExecutable(t, cli, "cronitor") + runFakeUpdate(t) + assertContains(t, cli, "new cronitor") + assertContains(t, dash, "new dashboard") +} + +func TestDashboardUpdateAlsoUpdatesCronitor(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("shell script fixtures") + } + fakeRelease(t) + dir := t.TempDir() + cli := installFake(t, dir, "cronitor") + dash := installFake(t, dir, DashboardBinaryName) + useExecutable(t, dash, DashboardBinaryName) + runFakeUpdate(t) + assertContains(t, dash, "new dashboard") + assertContains(t, cli, "new cronitor") +} + +func TestCronitorUpdateWithoutDashboardInstallsNoDashboard(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("shell script fixtures") + } + fakeRelease(t) + dir := t.TempDir() + cli := installFake(t, dir, "cronitor") + useExecutable(t, cli, "cronitor") + runFakeUpdate(t) + assertContains(t, cli, "new cronitor") + if _, err := os.Stat(filepath.Join(dir, DashboardBinaryName)); !os.IsNotExist(err) { + t.Errorf("dashboard was installed: %v", err) + } +} From 63152a2ff46cad45a4d6905fcdcfd67aa9c98ad2 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 6 Nov 2026 16:28:27 +0000 Subject: [PATCH 04/11] Make cronitor dash a launcher for crontab-dashboard The cronitor binary no longer contains the dashboard, its web assets, or the MCP server. `cronitor dash` finds crontab-dashboard (CRONTAB_DASHBOARD_BIN, then the folder that holds cronitor, then PATH) and execs `crontab-dashboard dash `. Every argument passes through as typed, including root flags before `dash`, with the environment and standard streams. On Unix the dashboard keeps the PID, signals, and exit status, so systemd units and MCP configs need no change. When crontab-dashboard is missing, `cronitor dash` exits 1 with a command that installs the matching release next to cronitor: curl -fsSL .../releases/download//crontab-dashboard__.tar.gz | tar -xz -C It adds sudo when that folder is not writable. Windows gets the .zip URL. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01B4Z4Doj15mT9bCnvdKp5UB --- cmd/dash.go | 101 +++++++++++++++++++++++++++++++++++ cmd/dash_launcher_test.go | 109 ++++++++++++++++++++++++++++++++++++++ cmd/dash_unix.go | 11 ++++ cmd/dash_windows.go | 23 ++++++++ main.go | 6 +-- main_test.go | 15 +++--- 6 files changed, 255 insertions(+), 10 deletions(-) create mode 100644 cmd/dash.go create mode 100644 cmd/dash_launcher_test.go create mode 100644 cmd/dash_unix.go create mode 100644 cmd/dash_windows.go diff --git a/cmd/dash.go b/cmd/dash.go new file mode 100644 index 00000000..83274c23 --- /dev/null +++ b/cmd/dash.go @@ -0,0 +1,101 @@ +package cmd + +import ( + "fmt" + "os" + "os/exec" + "path/filepath" + "runtime" + "strings" + + "github.com/spf13/cobra" +) + +var launchDashboard = execDashboard + +// dashLauncherCmd starts crontab-dashboard, which is released next to +// cronitor. Existing services and MCP configurations keep their command +// lines: all arguments, the environment, and standard streams pass through. +var dashLauncherCmd = &cobra.Command{ + Use: "dash", + Short: "Start the Crontab Guru Dashboard (crontab-dashboard)", + DisableFlagParsing: true, + Run: func(cmd *cobra.Command, args []string) { + path, err := dashboardExecutable() + if err != nil { + dir := filepath.Dir(cronitorPath()) + fatal(dashboardMissingMessage(Version, runtime.GOOS, runtime.GOARCH, dir, dirWritable(dir)), 1) + } + if err := launchDashboard(path, append([]string{"dash"}, args...), os.Environ()); err != nil { + fatal(fmt.Sprintf("Could not start %s: %v", path, err), 1) + } + }, +} + +// RegisterDashLauncher adds `cronitor dash`. crontab-dashboard registers the +// dashboard itself instead. +func RegisterDashLauncher() { + for _, c := range RootCmd.Commands() { + if c == dashLauncherCmd { + return + } + } + RootCmd.AddCommand(dashLauncherCmd) +} + +func cronitorPath() string { + if path, err := executablePath(); err == nil { + return path + } + return os.Args[0] +} + +// dashboardExecutable finds crontab-dashboard: CRONTAB_DASHBOARD_BIN, then +// the folder that holds cronitor, then PATH. +func dashboardExecutable() (string, error) { + if path := os.Getenv("CRONTAB_DASHBOARD_BIN"); path != "" { + return exec.LookPath(path) + } + name := DashboardBinaryName + if runtime.GOOS == "windows" { + name += ".exe" + } + if path, err := executablePath(); err == nil { + if sibling, err := exec.LookPath(filepath.Join(filepath.Dir(path), name)); err == nil { + return sibling, nil + } + } + return exec.LookPath(DashboardBinaryName) +} + +func dashboardMissingMessage(version, goos, goarch, dir string, writable bool) string { + url := fmt.Sprintf("https://github.com/cronitorio/cronitor-cli/releases/download/%s/%s_%s_%s", version, DashboardBinaryName, goos, goarch) + var install string + if goos == "windows" { + install = fmt.Sprintf("Download %s.zip\nand extract %s.exe into %s", url, DashboardBinaryName, dir) + } else { + sudo := "" + if !writable { + sudo = "sudo " + } + install = fmt.Sprintf("curl -fsSL %s.tar.gz | %star -xz -C %s", url, sudo, dir) + } + return strings.Join([]string{ + "The Crontab Guru Dashboard is now a separate program: " + DashboardBinaryName + ".", + "Your configuration and cron jobs are unchanged. To install it, run:", + "", + " " + install, + "", + "Then run 'cronitor dash' again, or '" + DashboardBinaryName + "'.", + }, "\n") +} + +func dirWritable(dir string) bool { + f, err := os.CreateTemp(dir, ".cronitor-write-check-") + if err != nil { + return false + } + f.Close() + os.Remove(f.Name()) + return true +} diff --git a/cmd/dash_launcher_test.go b/cmd/dash_launcher_test.go new file mode 100644 index 00000000..b0671b56 --- /dev/null +++ b/cmd/dash_launcher_test.go @@ -0,0 +1,109 @@ +package cmd + +import ( + "os" + "path/filepath" + "reflect" + "runtime" + "strings" + "testing" +) + +func TestDashLauncherForwardsArgumentsAndEnvironment(t *testing.T) { + RegisterDashLauncher() + bin := filepath.Join(t.TempDir(), DashboardBinaryName) + if err := os.WriteFile(bin, []byte("#!/bin/sh\nexit 0\n"), 0755); err != nil { + t.Fatal(err) + } + t.Setenv("CRONTAB_DASHBOARD_BIN", bin) + t.Setenv(varDashPassword, "fake-dash-password-not-real") + + oldLaunch := launchDashboard + t.Cleanup(func() { launchDashboard = oldLaunch; RootCmd.SetArgs([]string{}) }) + var gotPath string + var gotArgs, gotEnv []string + launchDashboard = func(path string, args, env []string) error { + gotPath, gotArgs, gotEnv = path, args, env + return nil + } + + RootCmd.SetArgs([]string{"--config", "/tmp/dash config.json", "dash", "--mcp-instance", "production", "--safe-mode"}) + if err := RootCmd.Execute(); err != nil { + t.Fatal(err) + } + if gotPath != bin { + t.Errorf("path = %q, want %q", gotPath, bin) + } + want := []string{"dash", "--config", "/tmp/dash config.json", "--mcp-instance", "production", "--safe-mode"} + if !reflect.DeepEqual(gotArgs, want) { + t.Errorf("args = %q, want %q", gotArgs, want) + } + if !strings.Contains(strings.Join(gotEnv, "\n"), varDashPassword+"=fake-dash-password-not-real") { + t.Error("environment not forwarded") + } +} + +func TestDashboardExecutableFindsSiblingOfCronitor(t *testing.T) { + dir := t.TempDir() + name := DashboardBinaryName + if runtime.GOOS == "windows" { + name += ".exe" + } + sibling := filepath.Join(dir, name) + if err := os.WriteFile(sibling, []byte("#!/bin/sh\nexit 0\n"), 0755); err != nil { + t.Fatal(err) + } + t.Setenv("CRONTAB_DASHBOARD_BIN", "") + t.Setenv("PATH", t.TempDir()) + oldPath := executablePath + executablePath = func() (string, error) { return filepath.Join(dir, "cronitor"), nil } + t.Cleanup(func() { executablePath = oldPath }) + + got, err := dashboardExecutable() + if err != nil || got != sibling { + t.Fatalf("dashboardExecutable() = %q, %v; want %q", got, err, sibling) + } +} + +func TestDashboardExecutableMissing(t *testing.T) { + t.Setenv("CRONTAB_DASHBOARD_BIN", "") + t.Setenv("PATH", t.TempDir()) + oldPath := executablePath + executablePath = func() (string, error) { return filepath.Join(t.TempDir(), "cronitor"), nil } + t.Cleanup(func() { executablePath = oldPath }) + if _, err := dashboardExecutable(); err == nil { + t.Fatal("found a dashboard that is not installed") + } +} + +func TestDashboardMissingMessage(t *testing.T) { + base := "https://github.com/cronitorio/cronitor-cli/releases/download/34.0/" + for _, tc := range []struct { + name, goos, goarch string + writable bool + want, notWant []string + }{ + {"linux writable", "linux", "amd64", true, + []string{"now a separate program", "unchanged", "curl -fsSL " + base + "crontab-dashboard_linux_amd64.tar.gz | tar -xz -C /usr/local/bin", "cronitor dash"}, + []string{"sudo"}}, + {"linux root dir", "linux", "arm64", false, + []string{"curl -fsSL " + base + "crontab-dashboard_linux_arm64.tar.gz | sudo tar -xz -C /usr/local/bin"}, nil}, + {"windows", "windows", "amd64", true, + []string{base + "crontab-dashboard_windows_amd64.zip", "crontab-dashboard.exe", "/usr/local/bin"}, + []string{"curl", "sudo"}}, + } { + t.Run(tc.name, func(t *testing.T) { + got := dashboardMissingMessage("34.0", tc.goos, tc.goarch, "/usr/local/bin", tc.writable) + for _, w := range tc.want { + if !strings.Contains(got, w) { + t.Errorf("message lacks %q:\n%s", w, got) + } + } + for _, w := range tc.notWant { + if strings.Contains(got, w) { + t.Errorf("message has %q:\n%s", w, got) + } + } + }) + } +} diff --git a/cmd/dash_unix.go b/cmd/dash_unix.go new file mode 100644 index 00000000..50a0614e --- /dev/null +++ b/cmd/dash_unix.go @@ -0,0 +1,11 @@ +//go:build !windows + +package cmd + +import "syscall" + +// execDashboard replaces this process, so the dashboard keeps the PID, +// signals, and exit status that `cronitor dash` had. +func execDashboard(path string, args, env []string) error { + return syscall.Exec(path, append([]string{path}, args...), env) +} diff --git a/cmd/dash_windows.go b/cmd/dash_windows.go new file mode 100644 index 00000000..14f58999 --- /dev/null +++ b/cmd/dash_windows.go @@ -0,0 +1,23 @@ +//go:build windows + +package cmd + +import ( + "os" + "os/exec" +) + +// execDashboard runs the dashboard with this process's streams and exits +// with its status. Windows has no exec. +func execDashboard(path string, args, env []string) error { + cmd := exec.Command(path, args...) + cmd.Env = env + cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr + if err := cmd.Run(); err != nil { + if exited, ok := err.(*exec.ExitError); ok { + exitFn(exited.ExitCode()) + } + return err + } + return nil +} diff --git a/main.go b/main.go index cad61d10..e6aecb37 100644 --- a/main.go +++ b/main.go @@ -4,7 +4,6 @@ import ( "os" "github.com/cronitorio/cronitor-cli/cmd" - "github.com/cronitorio/cronitor-cli/internal/dashboard" ) func main() { @@ -38,7 +37,8 @@ func main() { cmd.Execute() } -// registerCommands adds commands that live outside the cmd package. +// registerCommands adds commands that only the cronitor binary has. +// crontab-dashboard is built from cmd/crontab-dashboard. func registerCommands() { - dashboard.Register(cmd.RootCmd) + cmd.RegisterDashLauncher() } diff --git a/main_test.go b/main_test.go index 88c0542c..076e105e 100644 --- a/main_test.go +++ b/main_test.go @@ -6,9 +6,9 @@ import ( "github.com/cronitorio/cronitor-cli/cmd" ) -// The dashboard must stay registered on the CLI while its code lives in its -// own package. -func TestDashCommandIsRegistered(t *testing.T) { +// cronitor dash starts the separately installed crontab-dashboard. The CLI +// binary does not contain the dashboard. +func TestDashIsTheLauncher(t *testing.T) { registerCommands() found, _, err := cmd.RootCmd.Find([]string{"dash"}) if err != nil { @@ -17,9 +17,10 @@ func TestDashCommandIsRegistered(t *testing.T) { if found.Name() != "dash" { t.Fatalf("found %q, want dash", found.Name()) } - for _, flag := range []string{"port", "mcp-instance"} { - if found.Flags().Lookup(flag) == nil { - t.Errorf("dash is missing --%s", flag) - } + if !found.DisableFlagParsing { + t.Error("dash parses flags; the launcher must pass them through") + } + if found.Flags().Lookup("port") != nil { + t.Error("dash has --port; the dashboard is still built into cronitor") } } From e934080698e1a48a97f1bbfc53a7665ffafb556f Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 6 Nov 2026 16:31:34 +0000 Subject: [PATCH 05/11] Build the dashboard in its own CI and release jobs - Tests: the CLI jobs, including the two with the live API key, no longer install npm packages. A new dashboard job builds the frontend, runs tests/dashboard-smoke.sh, and packages one archive. - Release: the frontend builds once; a crontab-dashboard matrix with the same platforms as cronitor packages crontab-dashboard__ archives with scripts/package-dashboard.sh; publish verifies both sets. The cronitor build step is unchanged apart from dropping Node. - tests/dashboard-smoke.sh checks the missing-dashboard message, that `cronitor --config X dash --port N` execs crontab-dashboard and serves the UI with auth, and a clean SIGTERM exit. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01B4Z4Doj15mT9bCnvdKp5UB --- .github/workflows/release.yml | 104 ++++++++++++++++++++++++---------- .github/workflows/tests.yml | 84 ++++++++++----------------- scripts/package-dashboard.sh | 38 +++++++++++++ tests/dashboard-smoke.sh | 69 ++++++++++++++++++++++ tests/real-cron.sh | 2 - 5 files changed, 211 insertions(+), 86 deletions(-) create mode 100755 scripts/package-dashboard.sh create mode 100755 tests/dashboard-smoke.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6d24f89c..046ec1b0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -36,34 +36,6 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: '22' - cache: 'npm' - cache-dependency-path: web/package-lock.json - - - name: Install web dependencies - run: | - cd web - npm ci - - - name: Ensure static directory exists - run: | - mkdir -p web/static - ls -la web/ - - - name: Build web assets - run: | - cd web - echo "Starting web build..." - npm run build - echo "Web build completed" - - - name: Verify web assets were built - run: | - test -s web/static/index.html - - name: Go Release Binaries Normal Volume Size uses: wangyoucao577/go-release-action@v1.53 with: @@ -98,10 +70,76 @@ jobs: path: ${{ matrix.goos }}_${{ matrix.goarch }}.* if-no-files-found: error + build-web: + name: Build dashboard frontend + if: startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '22' + cache: 'npm' + cache-dependency-path: web/package-lock.json + + - name: Build web assets + working-directory: web + run: | + npm ci + npm run build + test -s static/index.html + + - uses: actions/upload-artifact@v4 + with: + name: web-static + path: web/static/ + if-no-files-found: error + + build-dashboard: + name: Create dashboard assets + needs: [build-web] + runs-on: ubuntu-latest + strategy: + max-parallel: 2 + matrix: + goos: [linux, windows, darwin, freebsd] + goarch: [amd64, arm, arm64] + exclude: + - goarch: arm + goos: darwin + - goarch: arm + goos: windows + - goarch: arm64 + goos: windows + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + + - uses: actions/download-artifact@v4 + with: + name: web-static + path: web/static + + - name: Build and package crontab-dashboard + run: scripts/package-dashboard.sh "${{ matrix.goos }}" "${{ matrix.goarch }}" . + + - name: Stage release assets + uses: actions/upload-artifact@v4 + with: + name: release-crontab-dashboard_${{ matrix.goos }}_${{ matrix.goarch }} + path: crontab-dashboard_${{ matrix.goos }}_${{ matrix.goarch }}.* + if-no-files-found: error + publish: name: Publish complete release runs-on: ubuntu-latest - needs: [build-binaries] + needs: [build-binaries, build-dashboard] permissions: contents: write steps: @@ -114,9 +152,13 @@ jobs: - name: Verify complete asset set and checksums working-directory: release-assets run: | - for target in linux_amd64 linux_arm linux_arm64 darwin_amd64 darwin_arm64 freebsd_amd64 freebsd_arm freebsd_arm64 windows_amd64; do + for target in linux_amd64 linux_arm linux_arm64 darwin_amd64 darwin_arm64 freebsd_amd64 freebsd_arm freebsd_arm64 windows_amd64 \ + crontab-dashboard_linux_amd64 crontab-dashboard_linux_arm crontab-dashboard_linux_arm64 \ + crontab-dashboard_darwin_amd64 crontab-dashboard_darwin_arm64 \ + crontab-dashboard_freebsd_amd64 crontab-dashboard_freebsd_arm crontab-dashboard_freebsd_arm64 \ + crontab-dashboard_windows_amd64; do extension=tar.gz - if [ "$target" = windows_amd64 ]; then extension=zip; fi + case "$target" in *windows_amd64) extension=zip ;; esac archive="$target.$extension" test -s "$archive" test -s "$archive.sha256" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2dd598e8..bea22e93 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -24,29 +24,6 @@ jobs: echo ::add-path::C:\msys64\usr\bin dir C:\msys64\usr\bin - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: '22' - cache: 'npm' - cache-dependency-path: web/package-lock.json - - - name: Install web dependencies - shell: bash - run: | - cd web - npm ci - - - name: Test dependency fixes - shell: bash - run: cd web && npm run test:dependencies - - - name: Build web assets - shell: bash - run: | - cd web - npm run build - - name: Setup BATS uses: mig4/setup-bats@v1 with: @@ -91,26 +68,6 @@ jobs: with: go-version-file: '${{ github.workspace }}/go.mod' - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: '22' - cache: 'npm' - cache-dependency-path: web/package-lock.json - - - name: Install web dependencies - run: | - cd web - npm ci - - - name: Test dependency fixes - run: cd web && npm run test:dependencies - - - name: Build web assets - run: | - cd web - npm run build - - name: Setup BATS uses: mig4/setup-bats@v1 with: @@ -161,6 +118,25 @@ jobs: go-version: 'stable' check-latest: true + - name: Build binary + run: go build -o cronitor main.go + + - name: Run Go tests + run: go test ./... + + # The dashboard frontend is the only npm build. It runs here, with no + # secrets; the CLI jobs above need no Node. + dashboard: + name: Build and smoke-test the dashboard + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v7 + + - uses: actions/setup-go@v7 + with: + go-version-file: '${{ github.workspace }}/go.mod' + - name: Set up Node.js uses: actions/setup-node@v4 with: @@ -169,17 +145,19 @@ jobs: cache-dependency-path: web/package-lock.json - name: Install web dependencies - run: | - cd web - npm ci + working-directory: web + run: npm ci + + - name: Test dependency fixes + working-directory: web + run: npm run test:dependencies - name: Build web assets - run: | - cd web - npm run build + working-directory: web + run: npm run build - - name: Build binary - run: go build -o cronitor main.go + - name: Smoke-test cronitor dash and crontab-dashboard + run: tests/dashboard-smoke.sh - - name: Run Go tests - run: go test ./... + - name: Package one release archive + run: scripts/package-dashboard.sh linux amd64 dist diff --git a/scripts/package-dashboard.sh b/scripts/package-dashboard.sh new file mode 100755 index 00000000..3b417e23 --- /dev/null +++ b/scripts/package-dashboard.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# Builds crontab-dashboard for one platform and writes the release archive +# with .sha256 and .md5 files, named like the cronitor assets: +# crontab-dashboard__.tar.gz (Windows: .zip) +# The binary is the archive's only file, which `cronitor update` expects. +# Run `npm run build` in web/ first. +# +# scripts/package-dashboard.sh linux amd64 dist +set -eu +goos=${1:?usage: package-dashboard.sh GOOS GOARCH OUTDIR} +goarch=${2:?usage: package-dashboard.sh GOOS GOARCH OUTDIR} +out=${3:?usage: package-dashboard.sh GOOS GOARCH OUTDIR} +root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) + +test -s "$root/web/static/index.html" || { echo "web/static/index.html is missing; run npm run build in web/" >&2; exit 1; } + +name=crontab-dashboard +binary=$name +[ "$goos" = windows ] && binary=$name.exe +asset=${name}_${goos}_${goarch} +mkdir -p "$out" +out=$(CDPATH= cd -- "$out" && pwd) +stage=$(mktemp -d) +trap 'rm -rf "$stage"' EXIT + +(cd "$root" && CGO_ENABLED=0 GOOS=$goos GOARCH=$goarch go build -trimpath -ldflags "-s -w" -o "$stage/$binary" ./cmd/crontab-dashboard) + +if [ "$goos" = windows ]; then + archive=$asset.zip + (cd "$stage" && zip -q "$out/$archive" "$binary") +else + archive=$asset.tar.gz + tar -czf "$out/$archive" -C "$stage" "$binary" +fi +cd "$out" +sha256sum "$archive" | cut -d ' ' -f 1 > "$archive.sha256" +md5sum "$archive" | cut -d ' ' -f 1 > "$archive.md5" +echo "$out/$archive" diff --git a/tests/dashboard-smoke.sh b/tests/dashboard-smoke.sh new file mode 100755 index 00000000..7fdb8d8e --- /dev/null +++ b/tests/dashboard-smoke.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +# Smoke test for the cronitor + crontab-dashboard pair. Builds both binaries +# and checks: +# 1. without crontab-dashboard, `cronitor dash` exits 1 with an install command +# 2. `cronitor --config X dash --port N` execs crontab-dashboard (same PID), +# serves the UI, requires auth, and uses the config given +# 3. SIGTERM stops it cleanly +# Needs the frontend: run `npm run build` in web/ first. +# +# tests/dashboard-smoke.sh +set -euo pipefail + +repo=$(cd "$(dirname "$0")/.." && pwd) +work=$(mktemp -d /tmp/crontab-dashboard-smoke.XXXXXX) +port=${PORT:-9311} +user=smoke +pass=smoke-password-not-real +pid= +cleanup() { + [ -n "$pid" ] && kill "$pid" 2>/dev/null || true + rm -rf "$work" +} +trap cleanup EXIT +fail() { echo "FAIL: $*" >&2; exit 1; } + +test -s "$repo/web/static/index.html" || fail "web/static/index.html is missing; run npm run build in web/" +mkdir -p "$work/bin" "$work/solo" +(cd "$repo" && go build -o "$work/bin/cronitor" . && go build -o "$work/bin/crontab-dashboard" ./cmd/crontab-dashboard) +cp "$work/bin/cronitor" "$work/solo/cronitor" + +# 1. No dashboard installed. +if out=$(env -i HOME="$work" PATH=/usr/bin:/bin "$work/solo/cronitor" dash 2>&1); then + fail "cronitor dash succeeded without crontab-dashboard" +fi +grep -q "releases/download/.*/crontab-dashboard_" <<<"$out" || fail "no install command in: $out" +grep -q -- "-C $work/solo" <<<"$out" || fail "install command does not target the cronitor folder: $out" +echo "ok 1 - missing dashboard prints an install command" + +# 2. Launch through cronitor dash. +env -i HOME="$work" PATH=/usr/bin:/bin CRONITOR_DASH_USER=$user CRONITOR_DASH_PASS=$pass \ + "$work/bin/cronitor" --config "$work/cronitor.json" dash --port "$port" > "$work/dash.log" 2>&1 & +pid=$! +for _ in $(seq 1 40); do + curl -s -o /dev/null "http://127.0.0.1:$port/" && break + sleep 0.25 +done +curl -s -o /dev/null "http://127.0.0.1:$port/" || { cat "$work/dash.log"; fail "dashboard did not start"; } + +comm=$(ps -o comm= -p "$pid") +[[ $comm == crontab-dash* ]] || fail "PID $pid runs '$comm', want crontab-dashboard (exec)" +page=$(curl -s -u "$user:$pass" "http://127.0.0.1:$port/") +grep -q '
' <<<"$page" || fail "UI not served: ${page:0:200}" +code=$(curl -s -o /dev/null -w '%{http_code}' "http://127.0.0.1:$port/api/settings") +[ "$code" = 401 ] || fail "API without auth returned $code, want 401" +settings=$(curl -s -u "$user:$pass" "http://127.0.0.1:$port/api/settings") +grep -q "\"config_file_path\":\"$work/cronitor.json\"" <<<"$settings" || fail "--config not passed through: ${settings:0:300}" +echo "ok 2 - cronitor dash runs crontab-dashboard with its flags" + +# 3. SIGTERM. The dashboard handles signals once it prints "Dashboard running". +for _ in $(seq 1 40); do + grep -q "Dashboard running" "$work/dash.log" && break + sleep 0.25 +done +kill -TERM "$pid" +status=0 +wait "$pid" || status=$? +pid= +[ "$status" = 0 ] || { cat "$work/dash.log"; fail "exit status $status after SIGTERM"; } +echo "ok 3 - SIGTERM stops the dashboard cleanly" diff --git a/tests/real-cron.sh b/tests/real-cron.sh index 9997efc3..e08cd937 100755 --- a/tests/real-cron.sh +++ b/tests/real-cron.sh @@ -26,8 +26,6 @@ mkdir -p "$out" "$work/bin" echo "work dir: $work" # 1. Build. Only the API host is changed; pings use CRONITOR_PING_API_HOST. -mkdir -p "$repo/web/static" -[ -e "$repo/web/static/index.html" ] || echo placeholder > "$repo/web/static/index.html" (cd "$repo" && go build -o "$work/bin/cronitor" \ -ldflags "-X github.com/cronitorio/cronitor-cli/lib.BaseURLOverride=http://127.0.0.1:$port/api" .) From 55cc9cc124949c903d42511b7dcb8bdab3bf973a Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 6 Nov 2026 16:37:41 +0000 Subject: [PATCH 06/11] Document crontab-dashboard as a separate program - README: how to install crontab-dashboard next to cronitor, that `cronitor dash` keeps working, and that `cronitor update` updates both. - MCP guide: the MCP server is part of the dashboard. - dockerfile: install crontab-dashboard from the latest release and start it directly. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01B4Z4Doj15mT9bCnvdKp5UB --- README.md | 26 +++++++++++++++++++------- dockerfile | 8 +++++++- docs/MCP_INTEGRATION.md | 4 ++-- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index a4805ecf..ead04ac0 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ CronitorCLI is the recommended companion application to the Cronitor monitoring service. Use it on your workstation and deploy it to your server for powerful features, including: * Import and sync all of your cron jobs with Cronitor -* Easily manage your cron jobs with the [web-based control panel](#crontab-guru-dashboard) +* Manage your cron jobs in a browser with the optional [Crontab Guru Dashboard](#crontab-guru-dashboard) * Automatic integration with Cronitor * Power tools for your cron jobs @@ -69,7 +69,7 @@ Logout revokes this installation's credential and removes it locally. **Schedule | `cronitor exec ` | Run a command with monitoring | | `cronitor list` | List all cron jobs | | `cronitor status` | View monitor status | -| `cronitor dash` | Start the web dashboard | +| `cronitor dash` | Start the Crontab Guru Dashboard (installed separately as `crontab-dashboard`) | #### How `cronitor sync` changes a crontab @@ -253,12 +253,24 @@ Team and API key commands need a credential from `cronitor auth login --admin` a ## Crontab Guru Dashboard -The Cronitor CLI bundles the [Crontab Guru Dashboard](https://crontab.guru/dashboard.html), a self‑hosted web UI to manage your cron jobs, including a one‑click “run now” and "suspend", a local console for testing jobs, and a built in MCP server for configuring jobs and checking the health/status of existing ones. +The [Crontab Guru Dashboard](https://crontab.guru/dashboard.html) is a self‑hosted web UI to manage your cron jobs, including a one‑click “run now” and "suspend", a local console for testing jobs, and a built in MCP server for configuring jobs and checking the health/status of existing ones. + +Since version 34.0 the dashboard is a separate program, `crontab-dashboard`, released with each CLI version. The `cronitor` binary does not include it. Your configuration, cron jobs, systemd units, and MCP settings do not change: `cronitor dash` starts `crontab-dashboard` with the same arguments. + +Install + +Put `crontab-dashboard` in the same folder as `cronitor` (Linux and macOS shown; use your platform and architecture, for example `darwin_arm64`). If `crontab-dashboard` is missing, `cronitor dash` prints this command with the right values: + +``` +curl -fsSL https://github.com/cronitorio/cronitor-cli/releases/latest/download/crontab-dashboard_linux_amd64.tar.gz | sudo tar -xz -C /usr/local/bin +``` + +On Windows, extract `crontab-dashboard.exe` from `crontab-dashboard_windows_amd64.zip` into the folder that holds `cronitor.exe`. `cronitor update` updates both programs when they are in the same folder. Start locally ``` -cronitor dash +cronitor dash # or: crontab-dashboard # then visit http://localhost:9000 ``` @@ -282,8 +294,8 @@ cronitor configure --users user1,user2 ``` ### Docker -The included `dockerfile` downloads and extracts the CLI for the target platform -(`amd64`, `arm64`, or `arm`). Credentials are supplied when the container starts; +The included `dockerfile` downloads and extracts the CLI and the dashboard for +the target platform (`amd64`, `arm64`, or `arm`). Credentials are supplied when the container starts; do not put them in Docker build arguments or Dockerfile `ENV` instructions. The dashboard reads these environment variables directly, so no `cronitor configure` step is needed. @@ -355,7 +367,7 @@ You can also pass `--ping-api-host eu.cronitor.link`, or save it with `cronitor ## MCP Server (AI Integration) -The Cronitor CLI includes a built-in [Model Context Protocol (MCP)](https://modelcontextprotocol.io) server for managing cron jobs with natural language through AI-powered tools like Claude Code, Cursor, Cline, and Windsurf. +The Crontab Guru Dashboard includes a built-in [Model Context Protocol (MCP)](https://modelcontextprotocol.io) server for managing cron jobs with natural language through AI-powered tools like Claude Code, Cursor, Cline, and Windsurf. **Quick start:** Run `cronitor dash` on your server, then configure your MCP client to spawn `cronitor dash --mcp-instance default`. diff --git a/dockerfile b/dockerfile index 741206e4..6a217276 100644 --- a/dockerfile +++ b/dockerfile @@ -18,8 +18,14 @@ RUN case "${TARGETARCH}" in amd64|arm64|arm) ;; \ chmod +x /usr/local/bin/cronitor && \ rm /tmp/cronitor.tar.gz +# Install the dashboard, released next to the CLI. +RUN curl -fsSL "https://github.com/cronitorio/cronitor-cli/releases/latest/download/crontab-dashboard_linux_${TARGETARCH}.tar.gz" -o /tmp/dashboard.tar.gz && \ + tar -xzf /tmp/dashboard.tar.gz -C /usr/local/bin crontab-dashboard && \ + chmod +x /usr/local/bin/crontab-dashboard && \ + rm /tmp/dashboard.tar.gz + # Supply CRONITOR_DASH_USER and CRONITOR_DASH_PASS at runtime. EXPOSE 9000 -CMD ["cronitor", "dash", "--port", "9000"] +CMD ["crontab-dashboard", "--port", "9000"] diff --git a/docs/MCP_INTEGRATION.md b/docs/MCP_INTEGRATION.md index eed828a8..3760006d 100644 --- a/docs/MCP_INTEGRATION.md +++ b/docs/MCP_INTEGRATION.md @@ -2,7 +2,7 @@ ## Overview -Cronitor CLI includes built-in support for the [Model Context Protocol (MCP)](https://modelcontextprotocol.io), enabling integration with AI-powered development tools like Claude Code, Cursor, Cline, Windsurf, and others. Manage cron jobs using natural language directly from your editor or terminal. +The Crontab Guru Dashboard includes built-in support for the [Model Context Protocol (MCP)](https://modelcontextprotocol.io), enabling integration with AI-powered development tools like Claude Code, Cursor, Cline, Windsurf, and others. Manage cron jobs using natural language directly from your editor or terminal. ## Features @@ -17,7 +17,7 @@ Cronitor CLI includes built-in support for the [Model Context Protocol (MCP)](ht The MCP integration has two components: -1. **Dashboard** (`cronitor dash`) - The web UI that manages cron jobs. This **must be running on the server where your cron jobs live**. +1. **Dashboard** (`cronitor dash`, or `crontab-dashboard`) - The web UI that manages cron jobs. Since CLI 34.0 it is a separate program; see [Install](../README.md#crontab-guru-dashboard). This **must be running on the server where your cron jobs live**. 2. **MCP Server** (`cronitor dash --mcp-instance`) - A bridge process that your AI tool spawns locally. It communicates with your AI tool via stdio and connects to the dashboard over HTTP. From c6c041ce4366fe7bde178955e4e76acd036c1254 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 6 Nov 2026 16:38:20 +0000 Subject: [PATCH 07/11] Add a real cron end-to-end test for the dashboard tests/real-cron-dashboard.sh builds cronitor and crontab-dashboard against a mock API, starts the dashboard through `cronitor dash`, and checks two real cron ticks: 1. Monitoring on through the dashboard API wraps the job with `cronitor exec`; the job runs and sends run and complete pings. 2. Monitoring off restores the original line; the job runs with no pings. The real-cron workflow (e2e label) runs it after tests/real-cron.sh. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01B4Z4Doj15mT9bCnvdKp5UB --- .github/workflows/real-cron.yml | 9 +- tests/real-cron-dashboard.sh | 142 ++++++++++++++++++++++++++++++++ 2 files changed, 149 insertions(+), 2 deletions(-) create mode 100755 tests/real-cron-dashboard.sh diff --git a/.github/workflows/real-cron.yml b/.github/workflows/real-cron.yml index 30cada99..50ff5977 100644 --- a/.github/workflows/real-cron.yml +++ b/.github/workflows/real-cron.yml @@ -1,7 +1,9 @@ name: "Real cron" # Runs tests/real-cron.sh: syncs a crontab with the shell shim, installs it -# for root, and checks three real cron ticks (about 4 minutes). +# for root, and checks three real cron ticks (about 4 minutes). Then runs +# tests/real-cron-dashboard.sh: toggles monitoring through crontab-dashboard +# and checks two more ticks (about 2 minutes). # Runs on a pull request that has the `e2e` label (and on each push while it # has it), or by hand from the Actions tab. on: @@ -14,7 +16,7 @@ jobs: name: Real cron end-to-end if: github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'e2e') runs-on: ubuntu-latest - timeout-minutes: 15 + timeout-minutes: 20 steps: - name: Checkout code uses: actions/checkout@v7 @@ -30,3 +32,6 @@ jobs: - name: Run real cron check run: sudo env "PATH=$PATH" "GOCACHE=$(go env GOCACHE)" "GOMODCACHE=$(go env GOMODCACHE)" tests/real-cron.sh + + - name: Run real cron dashboard check + run: sudo env "PATH=$PATH" "GOCACHE=$(go env GOCACHE)" "GOMODCACHE=$(go env GOMODCACHE)" tests/real-cron-dashboard.sh diff --git a/tests/real-cron-dashboard.sh b/tests/real-cron-dashboard.sh new file mode 100755 index 00000000..dde4074f --- /dev/null +++ b/tests/real-cron-dashboard.sh @@ -0,0 +1,142 @@ +#!/usr/bin/env bash +# End-to-end check of crontab-dashboard with real cron. Run as root on a +# disposable Linux box with cron installed: it replaces root's crontab and +# starts cron. CI runs it on the e2e label (.github/workflows/real-cron.yml). +# +# sudo tests/real-cron-dashboard.sh +# +# Both binaries are built with the API pointed at a local mock. The dashboard +# is started through `cronitor dash`, then: +# 1. turning monitoring on through the dashboard API wraps the job, and the +# next cron tick runs it with run + complete pings +# 2. turning monitoring off restores the line, and the next tick sends no pings +set -euo pipefail + +[ "$(id -u)" = 0 ] || { echo "run as root" >&2; exit 1; } +command -v cron >/dev/null || { echo "cron is not installed" >&2; exit 1; } + +repo=$(cd "$(dirname "$0")/.." && pwd) +work=$(mktemp -d /tmp/crontab-dashboard-e2e.XXXXXX) +out=$work/out +port=${PORT:-8766} +dash_port=${DASH_PORT:-9312} +auth=e2e:e2e-password-not-real +mkdir -p "$out" "$work/bin" +echo "work dir: $work" + +# 1. Build both binaries against the mock API. The frontend is not needed; +# the committed placeholder in web/static is enough for the API. +ldflags="-X github.com/cronitorio/cronitor-cli/lib.BaseURLOverride=http://127.0.0.1:$port/api" +(cd "$repo" && go build -o "$work/bin/cronitor" -ldflags "$ldflags" . \ + && go build -o "$work/bin/crontab-dashboard" -ldflags "$ldflags" ./cmd/crontab-dashboard) + +# 2. Mock API and ping receiver. Every request is logged to requests.log. +cat > "$work/mock.py" <<'PY' +import json, sys +from http.server import BaseHTTPRequestHandler, HTTPServer +log = open(sys.argv[2], "a", buffering=1) +class H(BaseHTTPRequestHandler): + def log_message(self, *a): pass + def reply(self, body): + data = json.dumps(body).encode() + self.send_response(200) + self.send_header("Content-Type", "application/json") + self.send_header("Content-Length", str(len(data))) + self.end_headers() + self.wfile.write(data) + def do_GET(self): + log.write("GET %s\n" % self.path) + if self.path.startswith("/api/monitors"): + return self.reply({"total_monitor_count": 0, "page_size": 50, "monitors": []}) + self.reply({}) + def do_PUT(self): + body = json.loads(self.rfile.read(int(self.headers["Content-Length"]))) + log.write("PUT %s\n" % self.path) + self.reply([{"key": m["key"], "attributes": {"key": m["key"], "code": "dash01"}} for m in body]) + do_POST = do_GET +HTTPServer(("127.0.0.1", int(sys.argv[1])), H).serve_forever() +PY +python3 "$work/mock.py" "$port" "$work/requests.log" & +mock=$! +dash= +trap 'kill $mock $dash 2>/dev/null; crontab -r 2>/dev/null || true' EXIT +sleep 1 + +# 3. Root crontab with one unmonitored job. +printf '%s\n' \ + "CRONITOR_PING_API_HOST=http://127.0.0.1:$port" \ + "PATH=$work/bin:/usr/bin:/bin" \ + "* * * * * echo tick >> $out/job.log" > "$work/crontab" +crontab "$work/crontab" +pgrep -x cron >/dev/null || cron +echo '{"CRONITOR_API_KEY":"real-cron-test-key-0000"}' > "$work/cronitor.json" + +# 4. Start the dashboard the way existing services do. +CRONITOR_DASH_USER=${auth%%:*} CRONITOR_DASH_PASS=${auth#*:} \ + "$work/bin/cronitor" --config "$work/cronitor.json" dash --port "$dash_port" > "$work/dash.log" 2>&1 & +dash=$! +for _ in $(seq 1 40); do + curl -s -o /dev/null "http://127.0.0.1:$dash_port/" && break + sleep 0.25 +done +curl -s -o /dev/null "http://127.0.0.1:$dash_port/" || { cat "$work/dash.log"; echo "dashboard did not start" >&2; exit 1; } + +api() { curl -fsS -u "$auth" -H 'Content-Type: application/json' "$@"; } +# set_monitored true|false: PUT the job back with monitoring changed, as the UI +# does. Each GET returns a one-time CSRF token that the PUT must send. +set_monitored() { + api -D "$work/headers" "http://127.0.0.1:$dash_port/api/jobs" > "$work/jobs.json" + local token + token=$(tr -d '\r' < "$work/headers" | sed -n 's/^[Xx]-[Cc][Ss][Rr][Ff]-[Tt]oken: //p') + python3 -I -c ' +import json, sys +jobs, marker, on = json.load(open(sys.argv[1])), sys.argv[2], sys.argv[3] == "true" +job = next(j for j in jobs if marker in j["command"]) +job["monitored"] = on +print(json.dumps(job)) +' "$work/jobs.json" "$out/job.log" "$1" > "$work/job.json" + api -X PUT -H "X-CSRF-Token: $token" --data @"$work/job.json" "http://127.0.0.1:$dash_port/api/jobs" > /dev/null +} + +count() { if [ -f "$1" ]; then grep -cF -- "${2:-}" "$1" || true; else echo 0; fi; } +wait_tick() { + local now + now=$(date +%s) + sleep $(( 60 - now % 60 + 10 )) +} +check() { + if [ "$2" = "$3" ]; then echo "ok $1 ($2)"; else echo "FAIL $1: got $2, want $3"; failed=1; fi +} +failed=0 + +# Tick 1: monitoring on. +set_monitored true +echo "--- crontab after monitoring on" +crontab -l +check "job wrapped with cronitor exec" "$(crontab -l | grep -c 'cronitor exec dash01 echo tick' || true)" 1 +: > "$work/requests.log" +wait_tick +echo "--- tick 1: monitored" +check "job ran" "$(count "$out/job.log" tick)" 1 +check "run ping" "$(count "$work/requests.log" '/dash01/run?')" 1 +check "complete ping" "$(count "$work/requests.log" '/dash01/complete?')" 1 + +# Tick 2: monitoring off. +set_monitored false +echo "--- crontab after monitoring off" +crontab -l +check "job unwrapped" "$(crontab -l | grep -cxF "* * * * * echo tick >> $out/job.log" || true)" 1 +: > "$work/requests.log" +wait_tick +echo "--- tick 2: unmonitored" +check "job ran" "$(count "$out/job.log" tick)" 2 +check "no pings" "$(count "$work/requests.log" '/dash01/')" 0 + +echo +if [ "$failed" = 0 ]; then + echo "ALL CHECKS PASSED" +else + echo "SOME CHECKS FAILED (logs in $work)" + cat "$work/dash.log" + exit 1 +fi From a8a0a44c059329a7110d0c38513ad8a38dec5f73 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 6 Nov 2026 16:38:20 +0000 Subject: [PATCH 08/11] Prepare CLI release 34.0 The major version marks the move of the dashboard into crontab-dashboard. Users of `cronitor dash` must install it next to cronitor; the release notes and the `cronitor dash` error give the command. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01B4Z4Doj15mT9bCnvdKp5UB --- cmd/root.go | 2 +- docs/releases/34.0.md | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 docs/releases/34.0.md diff --git a/cmd/root.go b/cmd/root.go index 69fb326b..f3a3b664 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -25,7 +25,7 @@ import ( "github.com/spf13/viper" ) -var Version string = "33.14" +var Version string = "34.0" var cfgFile string var userAgent string diff --git a/docs/releases/34.0.md b/docs/releases/34.0.md new file mode 100644 index 00000000..c710b9d1 --- /dev/null +++ b/docs/releases/34.0.md @@ -0,0 +1,19 @@ +## What's new + +### The dashboard is now a separate program + +- The Crontab Guru Dashboard is now `crontab-dashboard`, a second program in each release. The `cronitor` binary no longer contains the dashboard, its web frontend or its MCP server. The CLI build no longer needs Node or npm. +- **If you use `cronitor dash`, install `crontab-dashboard` in the same folder as `cronitor`.** Without it, `cronitor dash` stops with exit code 1 and prints the command to install it, for example: + + ``` + curl -fsSL https://github.com/cronitorio/cronitor-cli/releases/download/34.0/crontab-dashboard_linux_amd64.tar.gz | sudo tar -xz -C /usr/local/bin + ``` + +- Nothing else changes. `cronitor dash` starts `crontab-dashboard` with the same arguments, environment and configuration. systemd units, MCP settings (`cronitor dash --mcp-instance ...`), `/etc/cronitor/cronitor.json` and your cron jobs keep working. You can also run `crontab-dashboard` directly; it takes the same flags. +- `cronitor update` also updates `crontab-dashboard` when it is in the same folder. The dashboard's update button updates both programs. +- Release assets: `crontab-dashboard__.tar.gz` (Windows: `.zip`) for the same platforms as `cronitor`. The `cronitor` archives keep their names. +- The `dockerfile` installs both programs and starts `crontab-dashboard`. + +### Other changes + +- CI: the jobs that use the live API key no longer install npm packages. A separate job builds the frontend and runs `tests/dashboard-smoke.sh`. The `e2e` label also runs `tests/real-cron-dashboard.sh`, which turns monitoring on and off through the dashboard and checks real cron runs and pings. From 9380cfca4c0f0a8dc429c9433dea393e4935b001 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 6 Nov 2026 16:49:47 +0000 Subject: [PATCH 09/11] Fix the launcher test on Windows exec.LookPath on Windows only accepts files with an executable extension, so the fake dashboard needs .exe. Without it the launcher could not find it and exited the test binary. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01B4Z4Doj15mT9bCnvdKp5UB --- cmd/dash_launcher_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/dash_launcher_test.go b/cmd/dash_launcher_test.go index b0671b56..591bfad2 100644 --- a/cmd/dash_launcher_test.go +++ b/cmd/dash_launcher_test.go @@ -11,7 +11,12 @@ import ( func TestDashLauncherForwardsArgumentsAndEnvironment(t *testing.T) { RegisterDashLauncher() - bin := filepath.Join(t.TempDir(), DashboardBinaryName) + name := DashboardBinaryName + if runtime.GOOS == "windows" { + // exec.LookPath on Windows only accepts executable extensions. + name += ".exe" + } + bin := filepath.Join(t.TempDir(), name) if err := os.WriteFile(bin, []byte("#!/bin/sh\nexit 0\n"), 0755); err != nil { t.Fatal(err) } From 6df951079196efc9d64390f0f2e7c9f2a1af365f Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 6 Nov 2026 16:49:47 +0000 Subject: [PATCH 10/11] Handle dashboard stop signals from the start The dashboard registered its SIGINT/SIGTERM handler after starting the server, sleeping 500 ms, and opening the browser. A stop signal in that window killed it without a graceful shutdown (exit 143). It now registers the handler before the server starts. The smoke test sends SIGTERM as soon as the dashboard answers. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01B4Z4Doj15mT9bCnvdKp5UB --- internal/dashboard/dash.go | 9 +++++---- tests/dashboard-smoke.sh | 6 +----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/internal/dashboard/dash.go b/internal/dashboard/dash.go index a1994efd..cebb6ccd 100644 --- a/internal/dashboard/dash.go +++ b/internal/dashboard/dash.go @@ -965,6 +965,11 @@ not start a web server but instead communicates via stdio protocol.`, IdleTimeout: 60 * time.Second, } + // Handle stop signals before the server starts, so a stop sent right + // after start still shuts down gracefully. + c := make(chan os.Signal, 1) + signal.Notify(c, os.Interrupt, syscall.SIGTERM) + // Start the server in a goroutine go func() { fmt.Printf("Starting Cronitor dashboard on port %d...\n", port) @@ -981,10 +986,6 @@ not start a web server but instead communicates via stdio protocol.`, fmt.Printf("Opening browser to %s...\n", url) openBrowser(url) - // Wait for interrupt signal to gracefully shutdown - c := make(chan os.Signal, 1) - signal.Notify(c, os.Interrupt, syscall.SIGTERM) - fmt.Printf("Dashboard running on %s (Press Ctrl+C to stop)\n", url) <-c diff --git a/tests/dashboard-smoke.sh b/tests/dashboard-smoke.sh index 7fdb8d8e..46c1f2a9 100755 --- a/tests/dashboard-smoke.sh +++ b/tests/dashboard-smoke.sh @@ -56,11 +56,7 @@ settings=$(curl -s -u "$user:$pass" "http://127.0.0.1:$port/api/settings") grep -q "\"config_file_path\":\"$work/cronitor.json\"" <<<"$settings" || fail "--config not passed through: ${settings:0:300}" echo "ok 2 - cronitor dash runs crontab-dashboard with its flags" -# 3. SIGTERM. The dashboard handles signals once it prints "Dashboard running". -for _ in $(seq 1 40); do - grep -q "Dashboard running" "$work/dash.log" && break - sleep 0.25 -done +# 3. SIGTERM as soon as the dashboard answers. kill -TERM "$pid" status=0 wait "$pid" || status=$? From bad0691756597e690e4a06cac8151db4e5ade9d3 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 6 Nov 2026 20:04:40 +0000 Subject: [PATCH 11/11] Let crontab-dashboard run configure and update A standalone dashboard install should not need the cronitor command. `crontab-dashboard configure ...` and `crontab-dashboard update` now run those commands instead of starting the dashboard; update replaces the dashboard and the cronitor next to it. After first-run credentials are saved, the dashboard now says to run crontab-dashboard again. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01B4Z4Doj15mT9bCnvdKp5UB --- README.md | 2 +- cmd/crontab-dashboard/main.go | 11 ++++++++--- cmd/crontab-dashboard/main_test.go | 3 +++ docs/releases/34.0.md | 2 +- internal/dashboard/dash.go | 2 +- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ead04ac0..7df86e2f 100644 --- a/README.md +++ b/README.md @@ -265,7 +265,7 @@ Put `crontab-dashboard` in the same folder as `cronitor` (Linux and macOS shown; curl -fsSL https://github.com/cronitorio/cronitor-cli/releases/latest/download/crontab-dashboard_linux_amd64.tar.gz | sudo tar -xz -C /usr/local/bin ``` -On Windows, extract `crontab-dashboard.exe` from `crontab-dashboard_windows_amd64.zip` into the folder that holds `cronitor.exe`. `cronitor update` updates both programs when they are in the same folder. +On Windows, extract `crontab-dashboard.exe` from `crontab-dashboard_windows_amd64.zip` into the folder that holds `cronitor.exe`. `cronitor update` updates both programs when they are in the same folder. `crontab-dashboard configure` and `crontab-dashboard update` work the same as the `cronitor` commands, so a dashboard-only install never needs to call `cronitor`. Start locally diff --git a/cmd/crontab-dashboard/main.go b/cmd/crontab-dashboard/main.go index 44602af4..71f0f765 100644 --- a/cmd/crontab-dashboard/main.go +++ b/cmd/crontab-dashboard/main.go @@ -21,10 +21,15 @@ func setup() { dashboard.Register(cmd.RootCmd) } -// dashboardArgs runs the dash command unless it is already named, so -// `crontab-dashboard --port 9100` and `cronitor dash --port 9100` match. +// passThrough are the CLI commands crontab-dashboard runs as named, so a +// standalone install needs no `cronitor` command for settings and updates. +var passThrough = map[string]bool{"dash": true, "configure": true, "update": true} + +// dashboardArgs runs the dash command unless the first argument names a +// pass-through command, so `crontab-dashboard --port 9100` and +// `cronitor dash --port 9100` match. func dashboardArgs(args []string) []string { - if len(args) > 1 && args[1] == "dash" { + if len(args) > 1 && passThrough[args[1]] { return args } return append([]string{args[0], "dash"}, args[1:]...) diff --git a/cmd/crontab-dashboard/main_test.go b/cmd/crontab-dashboard/main_test.go index 9911666f..34b8965c 100644 --- a/cmd/crontab-dashboard/main_test.go +++ b/cmd/crontab-dashboard/main_test.go @@ -12,6 +12,9 @@ func TestDashboardArgsRunDash(t *testing.T) { {[]string{"crontab-dashboard"}, []string{"crontab-dashboard", "dash"}}, {[]string{"crontab-dashboard", "--port", "9100"}, []string{"crontab-dashboard", "dash", "--port", "9100"}}, {[]string{"crontab-dashboard", "dash", "--safe-mode"}, []string{"crontab-dashboard", "dash", "--safe-mode"}}, + // Settings and updates work without knowing about cronitor. + {[]string{"crontab-dashboard", "configure", "--users", "a,b"}, []string{"crontab-dashboard", "configure", "--users", "a,b"}}, + {[]string{"crontab-dashboard", "update"}, []string{"crontab-dashboard", "update"}}, } { if got := dashboardArgs(tc.in); !reflect.DeepEqual(got, tc.want) { t.Errorf("dashboardArgs(%q) = %q, want %q", tc.in, got, tc.want) diff --git a/docs/releases/34.0.md b/docs/releases/34.0.md index c710b9d1..6900b9bc 100644 --- a/docs/releases/34.0.md +++ b/docs/releases/34.0.md @@ -9,7 +9,7 @@ curl -fsSL https://github.com/cronitorio/cronitor-cli/releases/download/34.0/crontab-dashboard_linux_amd64.tar.gz | sudo tar -xz -C /usr/local/bin ``` -- Nothing else changes. `cronitor dash` starts `crontab-dashboard` with the same arguments, environment and configuration. systemd units, MCP settings (`cronitor dash --mcp-instance ...`), `/etc/cronitor/cronitor.json` and your cron jobs keep working. You can also run `crontab-dashboard` directly; it takes the same flags. +- Nothing else changes. `cronitor dash` starts `crontab-dashboard` with the same arguments, environment and configuration. systemd units, MCP settings (`cronitor dash --mcp-instance ...`), `/etc/cronitor/cronitor.json` and your cron jobs keep working. You can also run `crontab-dashboard` directly; it takes the same flags. `crontab-dashboard configure` and `crontab-dashboard update` work like the `cronitor` commands. - `cronitor update` also updates `crontab-dashboard` when it is in the same folder. The dashboard's update button updates both programs. - Release assets: `crontab-dashboard__.tar.gz` (Windows: `.zip`) for the same platforms as `cronitor`. The `cronitor` archives keep their names. - The `dockerfile` installs both programs and starts `crontab-dashboard`. diff --git a/internal/dashboard/dash.go b/internal/dashboard/dash.go index cebb6ccd..5ab9f6fa 100644 --- a/internal/dashboard/dash.go +++ b/internal/dashboard/dash.go @@ -703,7 +703,7 @@ not start a web server but instead communicates via stdio protocol.`, } fmt.Printf("\nCredentials saved to: %s\n", configPath) - fmt.Println("Please run 'cronitor dash' again to start the dashboard.") + fmt.Println("Please run 'crontab-dashboard' again to start the dashboard.") os.Exit(0) }