- Use Google Distroless images for all services (Go & Node.js). - Standardize documentation with [PROJECT-NAME].md. - Add .dockerignore and .gitignore to all projects. - Remove docker-compose.yml in favor of docker run instructions. - Fix Go version and dependency issues in observability, repo-integrations, and security-governance. - Add Podman support (fully qualified image names). - Update Dashboard to use Node.js static server for Distroless compatibility.
54 lines
1.3 KiB
Go
54 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"log/slog"
|
|
"os"
|
|
|
|
"github.com/lab/automation-jobs-core/temporal/activities"
|
|
"github.com/lab/automation-jobs-core/temporal/workflows"
|
|
"go.temporal.io/sdk/client"
|
|
"go.temporal.io/sdk/worker"
|
|
)
|
|
|
|
const (
|
|
SampleTaskQueue = "sample-task-queue"
|
|
)
|
|
|
|
func main() {
|
|
// Use slog for structured logging.
|
|
slog.SetDefault(slog.New(slog.NewJSONHandler(os.Stdout, nil)))
|
|
|
|
// Get Temporal server address from environment variable.
|
|
temporalAddress := os.Getenv("TEMPORAL_ADDRESS")
|
|
if temporalAddress == "" {
|
|
slog.Warn("TEMPORAL_ADDRESS not set, defaulting to localhost:7233")
|
|
temporalAddress = "localhost:7233"
|
|
}
|
|
|
|
// Create a new Temporal client.
|
|
c, err := client.Dial(client.Options{
|
|
HostPort: temporalAddress,
|
|
Logger: slog.Default(),
|
|
})
|
|
if err != nil {
|
|
slog.Error("Unable to create Temporal client", "error", err)
|
|
os.Exit(1)
|
|
}
|
|
defer c.Close()
|
|
|
|
// Create a new worker.
|
|
w := worker.New(c, SampleTaskQueue, worker.Options{})
|
|
|
|
// Register the workflow and activity.
|
|
w.RegisterWorkflow(workflows.SampleWorkflow)
|
|
w.RegisterActivity(activities.SampleActivity)
|
|
|
|
slog.Info("Starting Temporal worker", "task_queue", SampleTaskQueue)
|
|
|
|
// Start the worker.
|
|
err = w.Run(worker.InterruptCh())
|
|
if err != nil {
|
|
slog.Error("Unable to start worker", "error", err)
|
|
os.Exit(1)
|
|
}
|
|
}
|