Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 84 lines (65 sloc) 1.951 kB
#!/usr/bin/env ruby
require 'optparse'
###############################################################
## starts the server
###############################################################
def start_server()
pid_path = File.join(File.dirname(__FILE__), "src/mvs.pid")
if File.exists?(pid_path) == false
system("cd ./src; rackup -E production -p 80 -s Puma -P mvs.pid -D")
end
end
################################################################
## stop_server
################################################################
def stop_server()
pid_path = File.join(File.dirname(__FILE__), "src/mvs.pid")
if File.exists?(pid_path)
pid = File.open(pid_path).first.to_i
if pid > 1
Process.kill("TERM", pid)
end
end
end
################################################################
## starts the server in the development mode
################################################################
def devel_mode()
puts "Development Mode\n"
system("cd ./src; rackup -E development -p 8080 -s Puma")
end
################################################################
# change_directory
################################################################
def change_directory( path )
public_path = File.join(File.dirname(__FILE__), "src/public")
if File.exists?(public_path)
File.unlink(public_path)
end
File.symlink(path, public_path)
end
options = {}
optparse = OptionParser.new do |opts|
opts.banner = "Usage: mvsctl [options]"
opts.on('-s', '--start', 'Start Server') do
start_server
end
opts.on('-x', '--stop', 'Stop Server') do
stop_server
end
opts.on('-d', '--devel', 'Development Mode') do
devel_mode
end
opts.on('-c', '--change PATH', 'Change the movie directory') do |p|
change_directory p
end
opts.on('-h', '--help', 'Display this screen') do
puts opts
end
end
begin
optparse.parse!
rescue Exception => e
puts "Exception Occured: #{e}"
exit 1
end
Jump to Line
Something went wrong with that request. Please try again.