examples/source_dedicated.rb

Summary

Maintainability
A
0 mins
Test Coverage
#!/usr/bin/env ruby
# encoding: UTF-8
=begin
Copyright Alexander E. Fischer <aef@raxys.net>, 2009-2013

This file is part of Init.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
=end

# This must be set to an absolute path where attachable_daemon.rb is in.
$LOAD_PATH << File.expand_path('..', __FILE__)

require 'attachable_daemon'

# An intermediate class for Source engine game dedicated server daemons
class SourceDedicated < AttachableDaemon
  set(:sudo) { "sudo -u #{user}" }
  set(:tmux) { "tmux -S /run/tmux/#{session_name}" }

  set(:wrapper)    { "env RDTSC_FREQUENCY=#{frequency}" } 
  set(:executable) { working_directory + 'srcds_run' }
  set(:arguments)  { "-autoupdate -tickrate #{tickrate} -ip #{ip_address} -port #{port}" }
  set(:command)    { "#{wrapper} #{executable} #{arguments}" }
end