[server] host from args
This commit is contained in:
@@ -1,2 +1,4 @@
|
||||
all:
|
||||
hosts: shmyga.ru
|
||||
vars:
|
||||
service_host: 172.31.1.100
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
dest: "{{ project_dir }}/current"
|
||||
state: link
|
||||
|
||||
- name: "restart {{ project_name }} service"
|
||||
systemd:
|
||||
state: restarted
|
||||
name: "{{ project_name }}"
|
||||
#- name: "restart {{ project_name }} service"
|
||||
# systemd:
|
||||
# state: restarted
|
||||
# name: "{{ project_name }}"
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
git:
|
||||
repo: "{{ repo_url }}"
|
||||
dest: "{{ project_dir }}/repo"
|
||||
version: ansible
|
||||
|
||||
- name: Creates directory for release
|
||||
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_description: "{{ project_smartname }} server"
|
||||
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
|
||||
|
||||
@@ -40,7 +40,7 @@ const build = () => function build() {
|
||||
const test = (build) => function test() {
|
||||
const argv = yargs.argv;
|
||||
return build()
|
||||
.pipe(new Neko().run(argv.dev))
|
||||
.pipe(new Neko().run('localhost'))
|
||||
.pipe(debug());
|
||||
};
|
||||
|
||||
|
||||
@@ -31,9 +31,9 @@ class Init {
|
||||
private static function getHost():String {
|
||||
#if flash
|
||||
var url = Lib.current.loaderInfo.url;
|
||||
var r:EReg = ~/((app|https?):\/\/?[-_\w\d\.]+(:\d+)?)\/?/;
|
||||
if (r.match(url) && !(r.matched(2) == "app")) {
|
||||
return r.matched(1);
|
||||
var r:EReg = ~/(app|https?):\/\/?([-_\w\d\.]+)(:\d+)?\/?/;
|
||||
if (r.match(url) && !(r.matched(1) == "app")) {
|
||||
return r.matched(2);
|
||||
} else {
|
||||
return "localhost";
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import sys.net.Socket;
|
||||
|
||||
class Server extends ThreadServer<Session, Bytes> {
|
||||
|
||||
private static inline var TAG = "Server";
|
||||
private static inline var TAG = 'Server';
|
||||
|
||||
public function new() {
|
||||
super();
|
||||
@@ -26,16 +26,17 @@ class Server extends ThreadServer<Session, Bytes> {
|
||||
|
||||
override public function clientConnected(s:Socket):Session {
|
||||
var session = new Session(s);
|
||||
L.d(TAG, "Client connected");
|
||||
L.d(TAG, 'Client connected');
|
||||
return session;
|
||||
}
|
||||
|
||||
override public function clientDisconnected(session:Session) {
|
||||
L.d(TAG, "Client disconnected");
|
||||
L.d(TAG, 'Client disconnected');
|
||||
session.connection.handler.emit(ConnectionEvent.DISCONNECTED);
|
||||
}
|
||||
|
||||
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};
|
||||
}
|
||||
|
||||
@@ -52,12 +53,15 @@ class Server extends ThreadServer<Session, Bytes> {
|
||||
#if debug
|
||||
L.push(new SocketLogger());
|
||||
#end
|
||||
L.d(TAG, "Running");
|
||||
L.i(TAG, "Build: " + CompilationOption.get("build"));
|
||||
L.d(TAG, 'Running');
|
||||
L.i(TAG, 'Build: ${CompilationOption.get("build")}');
|
||||
Provider.setFactory(IConfigBundle, ServerConfigBundle);
|
||||
Provider.setFactory(ILevelBundle, ServerLevelBundle);
|
||||
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();
|
||||
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>;
|
||||
|
||||
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>();
|
||||
|
||||
@@ -53,6 +63,12 @@ class Session {
|
||||
connection.pushData(bytes);
|
||||
} else {
|
||||
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")) {
|
||||
connection = new NekoWebConnection<Response, Request>(socket, Request);
|
||||
} else {
|
||||
@@ -65,7 +81,7 @@ class Session {
|
||||
}
|
||||
|
||||
private function onConnectionEvent(event:ConnectionEvent):Void {
|
||||
L.d('Session', '${event}');
|
||||
L.d(TAG, '${event}');
|
||||
}
|
||||
|
||||
public function onRequest(request:Request):Void {
|
||||
|
||||
@@ -10,12 +10,12 @@ class Neko {
|
||||
this.tag = 'Neko';
|
||||
}
|
||||
|
||||
run() {
|
||||
run(...args) {
|
||||
let stream = null;
|
||||
const bufferContents = (file, enc, callback) => {
|
||||
log(this.tag, colors.cyan("run"), colors.magenta(file.path));
|
||||
|
||||
exec('.', ['neko', file.path].join(' '))
|
||||
exec('.', ['neko', file.path].concat(args).join(' '))
|
||||
.then(() => {
|
||||
stream.emit('end');
|
||||
callback();
|
||||
|
||||
Reference in New Issue
Block a user