[server] host from args
This commit is contained in:
@@ -1,2 +1,4 @@
|
|||||||
all:
|
all:
|
||||||
hosts: shmyga.ru
|
hosts: shmyga.ru
|
||||||
|
vars:
|
||||||
|
service_host: 172.31.1.100
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
dest: "{{ project_dir }}/current"
|
dest: "{{ project_dir }}/current"
|
||||||
state: link
|
state: link
|
||||||
|
|
||||||
- name: "restart {{ project_name }} service"
|
#- name: "restart {{ project_name }} service"
|
||||||
systemd:
|
# systemd:
|
||||||
state: restarted
|
# state: restarted
|
||||||
name: "{{ project_name }}"
|
# name: "{{ project_name }}"
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
git:
|
git:
|
||||||
repo: "{{ repo_url }}"
|
repo: "{{ repo_url }}"
|
||||||
dest: "{{ project_dir }}/repo"
|
dest: "{{ project_dir }}/repo"
|
||||||
|
version: ansible
|
||||||
|
|
||||||
- name: Creates directory for release
|
- name: Creates directory for release
|
||||||
file:
|
file:
|
||||||
|
|||||||
1
ansible/roles/setup/defaults/main.yml
Normal file
1
ansible/roles/setup/defaults/main.yml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
service_host: localhost
|
||||||
@@ -5,5 +5,5 @@ ansible_become_pass: 1234!QAZ
|
|||||||
service_name: "{{ project_name }}"
|
service_name: "{{ project_name }}"
|
||||||
service_description: "{{ project_smartname }} server"
|
service_description: "{{ project_smartname }} server"
|
||||||
service_work_dir: "{{ project_dir }}/current/target"
|
service_work_dir: "{{ project_dir }}/current/target"
|
||||||
service_command: "/usr/bin/neko {{ project_dir }}/current/target/{{ project_name }}.n"
|
service_command: "/usr/bin/neko {{ project_dir }}/current/target/{{ project_name }}.n {{ service_host }}"
|
||||||
service_user: www-data
|
service_user: www-data
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ const build = () => function build() {
|
|||||||
const test = (build) => function test() {
|
const test = (build) => function test() {
|
||||||
const argv = yargs.argv;
|
const argv = yargs.argv;
|
||||||
return build()
|
return build()
|
||||||
.pipe(new Neko().run(argv.dev))
|
.pipe(new Neko().run('localhost'))
|
||||||
.pipe(debug());
|
.pipe(debug());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -31,9 +31,9 @@ class Init {
|
|||||||
private static function getHost():String {
|
private static function getHost():String {
|
||||||
#if flash
|
#if flash
|
||||||
var url = Lib.current.loaderInfo.url;
|
var url = Lib.current.loaderInfo.url;
|
||||||
var r:EReg = ~/((app|https?):\/\/?[-_\w\d\.]+(:\d+)?)\/?/;
|
var r:EReg = ~/(app|https?):\/\/?([-_\w\d\.]+)(:\d+)?\/?/;
|
||||||
if (r.match(url) && !(r.matched(2) == "app")) {
|
if (r.match(url) && !(r.matched(1) == "app")) {
|
||||||
return r.matched(1);
|
return r.matched(2);
|
||||||
} else {
|
} else {
|
||||||
return "localhost";
|
return "localhost";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import sys.net.Socket;
|
|||||||
|
|
||||||
class Server extends ThreadServer<Session, Bytes> {
|
class Server extends ThreadServer<Session, Bytes> {
|
||||||
|
|
||||||
private static inline var TAG = "Server";
|
private static inline var TAG = 'Server';
|
||||||
|
|
||||||
public function new() {
|
public function new() {
|
||||||
super();
|
super();
|
||||||
@@ -26,16 +26,17 @@ class Server extends ThreadServer<Session, Bytes> {
|
|||||||
|
|
||||||
override public function clientConnected(s:Socket):Session {
|
override public function clientConnected(s:Socket):Session {
|
||||||
var session = new Session(s);
|
var session = new Session(s);
|
||||||
L.d(TAG, "Client connected");
|
L.d(TAG, 'Client connected');
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
override public function clientDisconnected(session:Session) {
|
override public function clientDisconnected(session:Session) {
|
||||||
L.d(TAG, "Client disconnected");
|
L.d(TAG, 'Client disconnected');
|
||||||
session.connection.handler.emit(ConnectionEvent.DISCONNECTED);
|
session.connection.handler.emit(ConnectionEvent.DISCONNECTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
override public function readClientMessage(session:Session, buf:Bytes, pos:Int, len:Int) {
|
override public function readClientMessage(session:Session, buf:Bytes, pos:Int, len:Int) {
|
||||||
|
//L.d(TAG, 'Client message: ${buf}');
|
||||||
return {msg: buf.sub(pos, len), bytes: len};
|
return {msg: buf.sub(pos, len), bytes: len};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,12 +53,15 @@ class Server extends ThreadServer<Session, Bytes> {
|
|||||||
#if debug
|
#if debug
|
||||||
L.push(new SocketLogger());
|
L.push(new SocketLogger());
|
||||||
#end
|
#end
|
||||||
L.d(TAG, "Running");
|
L.d(TAG, 'Running');
|
||||||
L.i(TAG, "Build: " + CompilationOption.get("build"));
|
L.i(TAG, 'Build: ${CompilationOption.get("build")}');
|
||||||
Provider.setFactory(IConfigBundle, ServerConfigBundle);
|
Provider.setFactory(IConfigBundle, ServerConfigBundle);
|
||||||
Provider.setFactory(ILevelBundle, ServerLevelBundle);
|
Provider.setFactory(ILevelBundle, ServerLevelBundle);
|
||||||
Provider.setFactory(IControlFactory, NoneControlFactory);
|
Provider.setFactory(IControlFactory, NoneControlFactory);
|
||||||
|
var host:String = Sys.args().length > 0 ? Sys.args()[0] : "localhost";
|
||||||
|
var port:Int = Sys.args().length > 1 ? Std.parseInt(Sys.args()[1]) : 5000;
|
||||||
var wserver = new Server();
|
var wserver = new Server();
|
||||||
wserver.run("localhost", 5000);
|
L.i(TAG, 'Start on ${host}:${port}');
|
||||||
|
wserver.run(host, port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -30,6 +30,16 @@ import sys.net.Socket;
|
|||||||
typedef ServerConnection = IConnection<Response, Request>;
|
typedef ServerConnection = IConnection<Response, Request>;
|
||||||
|
|
||||||
class Session {
|
class Session {
|
||||||
|
private static inline var TAG = 'Session';
|
||||||
|
|
||||||
|
private static var POLICY_FILE:String = [
|
||||||
|
'<?xml version="1.0"?>',
|
||||||
|
'<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">',
|
||||||
|
'<cross-domain-policy>',
|
||||||
|
'<site-control permitted-cross-domain-policies="master-only"/>',
|
||||||
|
'<allow-access-from domain="*" to-ports="*"/>',
|
||||||
|
'</cross-domain-policy>'
|
||||||
|
].join('\n');
|
||||||
|
|
||||||
public static var sessions:Map<String, Session> = new Map<String, Session>();
|
public static var sessions:Map<String, Session> = new Map<String, Session>();
|
||||||
|
|
||||||
@@ -53,6 +63,12 @@ class Session {
|
|||||||
connection.pushData(bytes);
|
connection.pushData(bytes);
|
||||||
} else {
|
} else {
|
||||||
var str:String = bytes.getString(0, bytes.length);
|
var str:String = bytes.getString(0, bytes.length);
|
||||||
|
if (str == '<policy-file-request/>' + String.fromCharCode(0)) {
|
||||||
|
L.d(TAG, 'policy-file-request');
|
||||||
|
socket.output.writeString(POLICY_FILE + String.fromCharCode(0));
|
||||||
|
socket.output.flush();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (StringTools.startsWith(str, "GET")) {
|
if (StringTools.startsWith(str, "GET")) {
|
||||||
connection = new NekoWebConnection<Response, Request>(socket, Request);
|
connection = new NekoWebConnection<Response, Request>(socket, Request);
|
||||||
} else {
|
} else {
|
||||||
@@ -65,7 +81,7 @@ class Session {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function onConnectionEvent(event:ConnectionEvent):Void {
|
private function onConnectionEvent(event:ConnectionEvent):Void {
|
||||||
L.d('Session', '${event}');
|
L.d(TAG, '${event}');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onRequest(request:Request):Void {
|
public function onRequest(request:Request):Void {
|
||||||
|
|||||||
@@ -10,12 +10,12 @@ class Neko {
|
|||||||
this.tag = 'Neko';
|
this.tag = 'Neko';
|
||||||
}
|
}
|
||||||
|
|
||||||
run() {
|
run(...args) {
|
||||||
let stream = null;
|
let stream = null;
|
||||||
const bufferContents = (file, enc, callback) => {
|
const bufferContents = (file, enc, callback) => {
|
||||||
log(this.tag, colors.cyan("run"), colors.magenta(file.path));
|
log(this.tag, colors.cyan("run"), colors.magenta(file.path));
|
||||||
|
|
||||||
exec('.', ['neko', file.path].join(' '))
|
exec('.', ['neko', file.path].concat(args).join(' '))
|
||||||
.then(() => {
|
.then(() => {
|
||||||
stream.emit('end');
|
stream.emit('end');
|
||||||
callback();
|
callback();
|
||||||
|
|||||||
Reference in New Issue
Block a user