[deploy] update
This commit is contained in:
6
capfile
6
capfile
@@ -1,5 +1,11 @@
|
|||||||
require 'capistrano/setup'
|
require 'capistrano/setup'
|
||||||
require 'capistrano/deploy'
|
require 'capistrano/deploy'
|
||||||
|
require 'capistrano/scm/git'
|
||||||
|
install_plugin Capistrano::SCM::Git
|
||||||
|
require 'capistrano/scm/git-with-submodules'
|
||||||
|
install_plugin Capistrano::SCM::Git::WithSubmodules
|
||||||
|
require 'capistrano/npm'
|
||||||
|
require 'capistrano/gulp'
|
||||||
require 'airbrussh/capistrano'
|
require 'airbrussh/capistrano'
|
||||||
|
|
||||||
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
|
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
|
||||||
|
|||||||
@@ -1,44 +1,27 @@
|
|||||||
require_relative 'service'
|
require_relative 'npm'
|
||||||
|
|
||||||
app = 'tankz'
|
app = 'tankz'
|
||||||
user = 'holop'
|
user = 'holop'
|
||||||
|
|
||||||
set :scm, :git
|
# git
|
||||||
set :application, app
|
set :application, app
|
||||||
set :repo_url, "git@bitbucket.org:shmyga/#{app}.git"
|
set :repo_url, "git@bitbucket.org:shmyga/#{app}.git"
|
||||||
set :user, user
|
set :user, user
|
||||||
set :deploy_to, "/home/#{user}/repo/#{app}"
|
set :deploy_to, "/home/#{user}/repo/#{app}"
|
||||||
|
|
||||||
|
# airbrussh
|
||||||
|
set :format, :airbrussh
|
||||||
|
set :format_options, command_output: false
|
||||||
|
|
||||||
namespace :build do
|
# npm
|
||||||
task :lib do
|
set :npm_target_path, -> { "/home/#{fetch(:user)}/npm" }
|
||||||
on roles(:app) do
|
set :npm_flags, '--silent --no-spin'
|
||||||
execute "mkdir ~/haxelib 2>/dev/null || :"
|
set :npm_roles, :web
|
||||||
execute "haxelib setup ~/haxelib"
|
set :npm_env_variables, {}
|
||||||
execute "haxelib install lime"
|
|
||||||
execute "haxelib install openfl"
|
|
||||||
execute "haxelib install protohx"
|
|
||||||
execute "haxelib install orm"
|
|
||||||
execute "haxelib git haxework git@bitbucket.org:shmyga/haxework.git"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
task :gen do
|
# gulp
|
||||||
on roles(:app) do
|
set :gulp_target_path, -> { release_path }
|
||||||
execute "cd #{release_path} && haxelib run protohx generate protohx.json"
|
set :gulp_tasks, 'client'
|
||||||
execute "cd #{release_path} && haxelib run orm mysql://shmyga:xkbp8jh9z2@localhost:3306/armageddon -s src-gen/haxe -c ru.m.tankz.db -a ru.m.tankz.db"
|
set :gulp_flags, '--no-color'
|
||||||
end
|
set :gulp_roles, :web
|
||||||
end
|
# before 'deploy:updated', 'gulp'
|
||||||
|
|
||||||
task :run do
|
|
||||||
on roles(:app) do
|
|
||||||
execute "cd #{release_path} && openfl build html5"
|
|
||||||
execute "cd #{release_path} && openfl build flash"
|
|
||||||
execute "cd #{release_path} && haxe server.hxml"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# before 'build:run', 'build:lib'
|
|
||||||
# before 'build:run', 'build:gen'
|
|
||||||
# before 'deploy:updated', 'build:run'
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ role :app, %w{localhost}
|
|||||||
role :web, %w{localhost}
|
role :web, %w{localhost}
|
||||||
role :db, %w{localhost}
|
role :db, %w{localhost}
|
||||||
|
|
||||||
|
set :user, ENV['USER']
|
||||||
user = fetch(:user)
|
user = fetch(:user)
|
||||||
|
|
||||||
server 'localhost', ssh_options: { port: 22, user: user, forward_agent: true }
|
server 'localhost', ssh_options: { port: 22, user: user, forward_agent: true }
|
||||||
|
|||||||
22
config/npm.rb
Normal file
22
config/npm.rb
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
set :npm_path, -> { release_path }
|
||||||
|
|
||||||
|
namespace :npm do
|
||||||
|
task :prepare do
|
||||||
|
on roles(:all) do
|
||||||
|
npm_target_path = fetch(:npm_target_path)
|
||||||
|
npm_path = fetch(:npm_path)
|
||||||
|
execute "mkdir -p #{npm_target_path}"
|
||||||
|
execute "cp #{npm_path}/package.json #{npm_target_path}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
task :link do
|
||||||
|
on roles(:all) do
|
||||||
|
npm_target_path = fetch(:npm_target_path)
|
||||||
|
npm_path = fetch(:npm_path)
|
||||||
|
execute "ln -s #{npm_target_path}/node_modules #{npm_path}/"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
before 'npm:install', 'npm:prepare'
|
||||||
|
after 'npm:install', 'npm:link'
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
module Service
|
|
||||||
class Manager
|
|
||||||
def initialize(env)
|
|
||||||
@env = env
|
|
||||||
end
|
|
||||||
|
|
||||||
def execute(action, command)
|
|
||||||
Airbrussh.configure do |config|
|
|
||||||
config.command_output = true
|
|
||||||
end
|
|
||||||
service_role = "service_role_#{action}".to_sym
|
|
||||||
role = fetch(service_role)
|
|
||||||
on roles(role) do
|
|
||||||
execute :sudo, "/bin/systemctl #{command} #{action}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
services = %w{tankz}
|
|
||||||
|
|
||||||
namespace :service do
|
|
||||||
task :restart, :param do |task, args|
|
|
||||||
services = args[:param] ? [args[:param]] : services
|
|
||||||
services.each { |service|
|
|
||||||
Service::Manager.new(self).execute(service, 'restart')
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
task :stop, :param do |task, args|
|
|
||||||
services = args[:param] ? [args[:param]] : services
|
|
||||||
services.each { |service|
|
|
||||||
Service::Manager.new(self).execute(service, 'stop')
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
task :start, :param do |task, args|
|
|
||||||
services = args[:param] ? [args[:param]] : services
|
|
||||||
services.each { |service|
|
|
||||||
Service::Manager.new(self).execute(service, 'start')
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
task :status, :param do |task, args|
|
|
||||||
services = args[:param] ? [args[:param]] : services
|
|
||||||
services.each { |service|
|
|
||||||
Service::Manager.new(self).execute(service, 'status')
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
set :service_role_tankz, :app
|
|
||||||
6
gemfile
Normal file
6
gemfile
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
source 'https://rubygems.org'
|
||||||
|
gem 'capistrano', '~> 3.7.0'
|
||||||
|
gem 'capistrano-git-with-submodules', '~> 2.0'
|
||||||
|
gem 'capistrano-npm'
|
||||||
|
gem 'capistrano-gulp'
|
||||||
|
gem 'airbrussh', :require => false
|
||||||
10
webapp/index.html
Normal file
10
webapp/index.html
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Tank'z</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Tank'z</h1>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user