snapshot of https://github.com/nats-io/nats-server.git (main, 2026-09-15; blobs > 131072B omitted)
Some checks failed
NATS Server Tests / Lint (push) Failing after 3s
NATS Server Tests / Build (Latest Go) (push) Has been skipped
NATS Server Tests / Build (Minimum Go) (push) Has been skipped
NATS Server Tests / Build (Minimum Go, windows-2022) (push) Has been skipped
NATS Server Tests / Build (Minimum Go, windows-2025) (push) Has been skipped
NATS Server Tests / Test Stores (push) Has been skipped
NATS Server Tests / Test JetStream (push) Has been skipped
NATS Server Tests / Test Raft (push) Has been skipped
NATS Server Tests / Test JetStream Consumers (push) Has been skipped
NATS Server Tests / Test JetStream Cluster 1 (push) Has been skipped
NATS Server Tests / Test JetStream Cluster 2 (push) Has been skipped
NATS Server Tests / Test JetStream Cluster 3 (push) Has been skipped
NATS Server Tests / Test JetStream Cluster 4 (push) Has been skipped
NATS Server Tests / Test JetStream Supercluster (push) Has been skipped
NATS Server Tests / Test No-Race 1 (push) Has been skipped
NATS Server Tests / Test No-Race 2 (push) Has been skipped
NATS Server Tests / Test MQTT (push) Has been skipped
NATS Server Tests / Test Message Tracing (push) Has been skipped
NATS Server Tests / Test JWT (push) Has been skipped
NATS Server Tests / Test Remaining Server Tests (push) Has been skipped
NATS Server Tests / Test Other Packages (push) Has been skipped
Vulnerability Scan / govulncheck (push) Failing after 12m2s
Some checks failed
NATS Server Tests / Lint (push) Failing after 3s
NATS Server Tests / Build (Latest Go) (push) Has been skipped
NATS Server Tests / Build (Minimum Go) (push) Has been skipped
NATS Server Tests / Build (Minimum Go, windows-2022) (push) Has been skipped
NATS Server Tests / Build (Minimum Go, windows-2025) (push) Has been skipped
NATS Server Tests / Test Stores (push) Has been skipped
NATS Server Tests / Test JetStream (push) Has been skipped
NATS Server Tests / Test Raft (push) Has been skipped
NATS Server Tests / Test JetStream Consumers (push) Has been skipped
NATS Server Tests / Test JetStream Cluster 1 (push) Has been skipped
NATS Server Tests / Test JetStream Cluster 2 (push) Has been skipped
NATS Server Tests / Test JetStream Cluster 3 (push) Has been skipped
NATS Server Tests / Test JetStream Cluster 4 (push) Has been skipped
NATS Server Tests / Test JetStream Supercluster (push) Has been skipped
NATS Server Tests / Test No-Race 1 (push) Has been skipped
NATS Server Tests / Test No-Race 2 (push) Has been skipped
NATS Server Tests / Test MQTT (push) Has been skipped
NATS Server Tests / Test Message Tracing (push) Has been skipped
NATS Server Tests / Test JWT (push) Has been skipped
NATS Server Tests / Test Remaining Server Tests (push) Has been skipped
NATS Server Tests / Test Other Packages (push) Has been skipped
Vulnerability Scan / govulncheck (push) Failing after 12m2s
This commit is contained in:
135
main.go
Normal file
135
main.go
Normal file
@@ -0,0 +1,135 @@
|
||||
// Copyright 2012-2026 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package main
|
||||
|
||||
//go:generate go run server/errors_gen.go
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/nats-io/nats-server/v2/server"
|
||||
)
|
||||
|
||||
var usageStr = `
|
||||
Usage: nats-server [options]
|
||||
|
||||
Server Options:
|
||||
-a, --addr, --net <host> Bind to host address (default: 0.0.0.0)
|
||||
-p, --port <port> Use port for clients (default: 4222)
|
||||
-n, --name
|
||||
--server_name <server_name> Server name (default: auto)
|
||||
-P, --pid <file> File to store PID
|
||||
-m, --http_port <port> Use port for http monitoring
|
||||
-ms,--https_port <port> Use port for https monitoring
|
||||
-c, --config <file> Configuration file
|
||||
-t Test configuration and exit
|
||||
-sl,--signal <signal>[=<pid>] Send signal to nats-server process (ldm, stop, quit, term, reopen, reload)
|
||||
<pid> can be either a PID (e.g. 1) or the path to a PID file (e.g. /var/run/nats-server.pid)
|
||||
--client_advertise <string> Client URL to advertise to other servers
|
||||
--ports_file_dir <dir> Creates a ports file in the specified directory (<executable_name>_<pid>.ports).
|
||||
|
||||
Logging Options:
|
||||
-l, --log <file> File to redirect log output
|
||||
-T, --logtime Timestamp log entries (default: true)
|
||||
--logtime_utc Timestamps in UTC instead of local timezone (default: false)
|
||||
-s, --syslog Log to syslog or windows event log
|
||||
-r, --remote_syslog <addr> Syslog server addr (udp://localhost:514)
|
||||
-D, --debug Enable debugging output
|
||||
-V, --trace Trace the raw protocol
|
||||
-VV Verbose trace (traces system account as well)
|
||||
-DV Debug and trace
|
||||
-DVV Debug and verbose trace (traces system account as well)
|
||||
--log_size_limit <limit> Logfile size limit (default: auto)
|
||||
--max_traced_msg_len <len> Maximum printable length for traced messages (default: unlimited)
|
||||
|
||||
JetStream Options:
|
||||
-js, --jetstream Enable JetStream functionality
|
||||
-sd, --store_dir <dir> Set the storage directory
|
||||
|
||||
Authorization Options:
|
||||
--user <user> User required for connections
|
||||
--pass <password> Password required for connections
|
||||
--auth <token> Authorization token required for connections
|
||||
|
||||
TLS Options:
|
||||
--tls Enable TLS, do not verify clients (default: false)
|
||||
--tlscert <file> Server certificate file
|
||||
--tlskey <file> Private key for server certificate
|
||||
--tlsverify Enable TLS, verify client certificates
|
||||
--tlscacert <file> Client certificate CA for verification
|
||||
|
||||
Cluster Options:
|
||||
--routes <rurl-1, rurl-2> Routes to solicit and connect
|
||||
--cluster <cluster-url> Cluster URL for solicited routes
|
||||
--cluster_name <string> Cluster Name, if not set one will be dynamically generated
|
||||
--no_advertise <bool> Do not advertise known cluster information to clients
|
||||
--cluster_advertise <string> Cluster URL to advertise to other servers
|
||||
--connect_retries <number> For implicit routes, number of connect retries
|
||||
--cluster_listen <url> Cluster url from which members can solicit routes
|
||||
|
||||
Profiling Options:
|
||||
--profile <port> Profiling HTTP port
|
||||
|
||||
Common Options:
|
||||
-h, --help Show this message
|
||||
-v, --version Show version
|
||||
--help_tls TLS help
|
||||
`
|
||||
|
||||
// usage will print out the flag options for the server.
|
||||
func usage() {
|
||||
fmt.Printf("%s\n", usageStr)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
func main() {
|
||||
exe := "nats-server"
|
||||
|
||||
// Create a FlagSet and sets the usage
|
||||
fs := flag.NewFlagSet(exe, flag.ExitOnError)
|
||||
fs.Usage = usage
|
||||
|
||||
// Configure the options from the flags/config file
|
||||
opts, err := server.ConfigureOptions(fs, os.Args[1:],
|
||||
server.PrintServerAndExit,
|
||||
fs.Usage,
|
||||
server.PrintTLSHelpAndDie)
|
||||
if err != nil {
|
||||
server.PrintAndDie(fmt.Sprintf("%s: %s", exe, err))
|
||||
} else if opts.CheckConfig {
|
||||
fmt.Fprintf(os.Stderr, "%s: configuration file %s is valid (%s)\n", exe, opts.ConfigFile, opts.ConfigDigest())
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
// Redact secret arguments before expvar reads them.
|
||||
server.RedactArgs(os.Args)
|
||||
|
||||
// Create the server with appropriate options.
|
||||
s, err := server.NewServer(opts)
|
||||
if err != nil {
|
||||
server.PrintAndDie(fmt.Sprintf("%s: %s", exe, err))
|
||||
}
|
||||
|
||||
// Configure the logger based on the flags.
|
||||
s.ConfigureLogger()
|
||||
|
||||
// Start things up. Block here until done.
|
||||
if err := server.Run(s); err != nil {
|
||||
server.PrintAndDie(err.Error())
|
||||
}
|
||||
|
||||
s.WaitForShutdown()
|
||||
}
|
||||
Reference in New Issue
Block a user