Class: Merb::Server

Class | Merb::Server
In: | lib/merb-core/server.rb
Parent: | Object

Server encapsulates the management of Merb daemons.

### Methods

_change_privilege add_irb_trap alive? bootup change_privilege daemonize kill kill_pid pid_file pid_files pid_in_file remove_pid remove_pid_file shutdown start store_details store_pid

### Public Class methods

_change_privilege(user, group=user)

Change privileges of the process to the specified user and group.

#### Parameters

user<String>: | The user to change the process to.
group<String>: | The group to change the process to.

#### Alternatives

If group is left out, the user will be used as the group.

:api: private

add_irb_trap()

Add trap to enter IRB on SIGINT. Process exit if second SIGINT is received.

:api: private

alive?(port)

#### Parameters

port<~to_s>: | The port to check for Merb instances on.

#### Returns

Boolean: | True if Merb is running on the specified port.

:api: private

bootup()

Starts up Merb by running the bootloader and starting the adapter.

:api: private

change_privilege()

Change process user/group to those specified in Merb::Config.

:api: private

daemonize(port)

#### Parameters

port<~to_s>: | The port of the Merb process to daemonize.

:api: private

kill(port, sig = "INT")

#### Parameters

port<~to_s>: | The port of the Merb process to kill.
sig<~to_s>: | The signal to send to the process, the default is 9 - SIGKILL.

No Name Default Action Description 1 SIGHUP terminate process terminal line hangup 2 SIGINT terminate process interrupt program 3 SIGQUIT create core image quit program 4 SIGILL create core image illegal instruction 9 SIGKILL terminate process kill program 15 SIGTERM terminate process software termination signal 30 SIGUSR1 terminate process User defined signal 1 31 SIGUSR2 terminate process User defined signal 2

#### Alternatives

If you pass "all" as the port, the signal will be sent to all Merb processes.

:api: private

kill_pid(sig, file)

Sends the provided signal to the process pointed at by the provided pid file. :api: private

pid_file(port)

Gets the pid file for the specified port/socket.

#### Parameters

port<~to_s>: | The port/socket of the Merb process to whom the the PID file belongs to.

#### Returns

String: | Location of pid file for specified port. If clustered and pid_file option is specified, it adds the port/socket value to the path.

:api: private

pid_files()

Get a list of the pid files.

#### Returns

Array: | List of pid file paths. If not running clustered, the array contains a single path.

:api: private

pid_in_file(pidfile)

:api: private

remove_pid(port)

Delete the pidfile for the specified port/socket.

:api: private

remove_pid_file(port)

Removes a PID file used by the server from the filesystem. This uses :pid_file options from configuration when provided or merb.<port/socket>.pid in log directory by default.

#### Parameters

port<~to_s>: | The port of the Merb process to whom the the PID file belongs to.

#### Alternatives

If Merb::Config[:pid_file] has been specified, that will be used instead of the port/socket based PID file.

:api: private

shutdown(status = 0)

Shut down Merb, reap any workers if necessary.

:api: private

start(port, cluster=nil)

Start a Merb server, in either foreground, daemonized or cluster mode.

#### Parameters

port<~to_i>: | The port to which the first server instance should bind to. Subsequent server instances bind to the immediately following ports.
cluster<~to_i>: | Number of servers to run in a cluster.

#### Alternatives

If cluster is left out, then one process will be started. This process will be daemonized if Merb::Config[:daemonize] is true.

:api: private

store_details(port = nil)

Stores a PID file on the filesystem. This uses :pid_file options from configuration when provided or merb.<port/socket>.pid in log directory by default.

#### Parameters

port<~to_s>: | The port of the Merb process to whom the the PID file belongs to.

#### Alternatives

If Merb::Config[:pid_file] has been specified, that will be used instead of the port/socket based PID file.

:api: private

store_pid(port)

Stores a PID file on the filesystem. This uses :pid_file options from configuration when provided or merb.<port>.pid in log directory by default.

#### Parameters

port<~to_s>: | The port of the Merb process to whom the the PID file belongs to.

#### Alternatives

If Merb::Config[:pid_file] has been specified, that will be used instead of the port/socket based PID file.

:api: private

[Validate]