Runtime.start_server
Starts a private tmux server and resolves to the libtmux.OwnedServer that owns it.
Source and package
- Qualified name
-
libtmux.Runtime: start _server - Module
- libtmux
- Declared in
Runtime- Package
- libtmux
- Source
- lua/libtmux/_internal/runtime.lua
- start_server: fun( self: libtmux
.Runtime , options: libtmux.Start , ):libtmuxServer Options .Request <libtmux.Owned >Server -
- Parameters
-
-
options(libtmux.Start ) – Options forServer Options libtmux.Runtime:start_server().binaryis the only required field. The server lives in a fresh directory underroot, with its socket inside, sorootplus about 45 bytes must fit a socket path (sun_path: 107 bytes on Linux, 103 on macOS and the BSDs); a longer root fails withinvalid_endpointbefore anything is created. The directory holds the daemon'sTMUX_TMPDIR, so a tmux client that names no socket cannot reach another server from inside it. The daemon inherits the caller's environment lessTMUX,TMUX_PANEand everyLIBTMUX_SOCKET*variable, plusenvironment.environmentcannot set those names orTMUX_TMPDIR. The daemon runs withexit-empty off, so it stays up with no session.
-
Examples
Start a private tmux server, create a session on it, and stop it. Use Lua 5.1 or newer with LuaRocks, tmux 3.3a or newer, and a C compiler and CMake for luv on Linux. In a new directory, install the library and its standalone runtime dependency from LuaRocks:
Terminal window $ luarocks --tree ./rocks install luv &&luarocks --tree ./rocks install libtmux &&eval "$(luarocks --tree ./rocks path)"Save the complete program as
start_server.lua. It starts its own private tmux server, uses it and stops it, so no existing session is needed. View sourcestart_server.luaComplete program local adapter = require("libtmux.runtime.luv")local function must(value, err)if err ~= nil thenerror(tostring(err), 0)endreturn valueend-- tmux is /usr/bin/tmux unless TMUX_BIN names another absolute path.local binary = os.getenv("TMUX_BIN") or "/usr/bin/tmux"must(adapter.run(function(runtime)-- The server is private: its own directory, socket and environment.local owned = must(runtime:start_server({ binary = binary }):await())local server = owned.serverlocal before = must(server:snapshot():await())must(server:new_session({ name = "demo", argv = { "/bin/cat" } }):await())local after = must(server:snapshot():await())print(("sessions: %d, then %d"):format(#before.sessions, #after.sessions))must(owned:stop():await())return trueend))Run the saved program. It runs
/usr/bin/tmux; setTMUX_BINto another absolute path to use a different binary. Assertions and operation errors produce a failing exit status:Terminal window $ eval "$(luarocks --tree ./rocks path)" &&lua start_server.lua
Recorded calls
source callsThe Lua reference records declarations, not calls, so this page shows no callers or callees. That is a limit of the extracted data, not a statement that nothing calls libtmux.Runtime:start_server.
Guides
task materialPages that discuss start_server.