The online racing simulator
Console Dedicated Host TEST 2
1
(30 posts, closed, started )
Console Dedicated Host TEST 2
Hello Hosters,

Here is the second test of the long requested console based dedicated host.

Yesterday's version seemed to work well, but did not accept text input. This one does, but it is invisible while you type. This is to totally separate stdin and stdout which I believe can be quite helpful. I don't know much about this kind of thing but I think you can get your input from where you want and send the output where you want.

Also, I've removed all libraries that I could from the linker and in doing so removed various unnecessary calls to Windows functions, which may be helpful when connecting to external systems (e.g. Wine). It's cleaner anyway.

I think it still needs :

A command to optionally remove colour codes
A command to optionally replace "high ascii" (c > 126) with question marks
Some status commands, e.g. who is connected and which track you are at

Save DCon.exe into a DEDI folder then you can run it as usual with a command line or a setup.cfg file.
Attached files
DCon_TEST2.zip - 358.5 KB - 376 views
Quote from Scawen :From a quick look, I can't see how to do colour. How to do it seems to depend on where the output is going. I can only see how to do colour on Linux consoles, not Windows.

This works on Windows, but doesn't seem to work with WINE:

http://msdn.microsoft.com/en-g ... s686047%28v=vs.85%29.aspx
#include <iostream>
#include <windows.h>

using namespace std;

/*
defined by Wincon.h:
FOREGROUND_BLUE = 1
FOREGROUND_GREEN = 2
FOREGROUND_RED = 4
FOREGROUND_INTENSITY = 8
BACKGROUND_BLUE = 16
BACKGROUND_GREEN = 32
BACKGROUND_RED = 64
BACKGROUND_INTENSITY = 128
*/

#define BLACK 0 + 16 + 32 + 64
#define RED 4 + 8
#define GREEN 2 + 8
#define YELLOW 2 + 4 + 8
#define BLUE 1 + 8
#define MAGENTA 1 + 4 + 8
#define CYAN 1 + 2 + 8
#define WHITE 1 + 2 + 4 + 8
#define GREY 1 + 2 + 4

int main()
{
HANDLE hCons;
hCons = GetStdHandle(STD_OUTPUT_HANDLE);

SetConsoleTextAttribute(hCons,YELLOW);
cout << "Live";
SetConsoleTextAttribute(hCons,WHITE);
cout << "For";
SetConsoleTextAttribute(hCons,CYAN);
cout << "Speed" << endl;
SetConsoleTextAttribute(hCons,GREY); //this is needed or the colour won't reset after the program has terminated
}

Regardless, trying to get colours to work properly in the console is probably more trouble than it's worth.


Quote from Scawen :I think there should be an option to show the text with or without ^X colour codes.

That would be a good idea I think.

It would also be nice to have an option to not show the messages as well - as TAA (kind of) said, it's not really needed when LFS is configured to start up at boot, but would be nice to have in some situations.


It is possible to have messages displayed in the top x lines of the console, while leaving the bottom line clear to type commands. It's been several years since I've done anything like that though, so I'll have to look up how. Something tells me implementation would also be different for Windows and Linux, as with practically everything else on the console, but that's probably more likely to work with WINE than colours.
Doing it like this would probably break the stdin/out functionality though.


*this is all based on TEST 1, I was writing this just as you posted the new one.
DCon TEST2 seems to have got rid of all the X errors & warnings

$ wine DCon.exe
Track loaded

Quote from Scawen :Hello Hosters,

Here is the second test of the long requested console based dedicated host.

Yesterday's version seemed to work well, but did not accept text input. This one does, but it is invisible while you type. This is to totally separate stdin and stdout which I believe can be quite helpful. I don't know much about this kind of thing but I think you can get your input from where you want and send the output where you want.

Also, I've removed all libraries that I could from the linker and in doing so removed various unnecessary calls to Windows functions, which may be helpful when connecting to external systems (e.g. Wine). It's cleaner anyway.

I think it still needs :

A command to optionally remove colour codes
A command to optionally replace "high ascii" (c > 126) with question marks
Some status commands, e.g. who is connected and which track you are at

Save DCon.exe into a DEDI folder then you can run it as usual with a command line or a setup.cfg file.

Hi Scawen:

I've started it on my server and it appears to work. I've ran a few commands and no errors.

Thank you for this It's great

Degats: running "wine DCon.exe" will never work with colours. however running wineconsole it will. running CLI apps in "wine" run in this lazy mode that just spit data out to the console. It combines stdout and stderr and just jams it in a mess. Wineconsole however actually properly emulates a console window (best when running --backend=curses, else X will try to start still).
Quote from Degats :DCon TEST2 seems to have got rid of all the X errors & warnings

That sounds good.

Dustin, are those the window issues you were talking about on the other thread?

Looks like removing the unnecessary windows functions was a good idea...
Quote from dawesdust_12 :Degats: running "wine DCon.exe" will never work with colours. however running wineconsole it will. running CLI apps in "wine" run in this lazy mode that just spit data out to the console. It combines stdout and stderr and just jams it in a mess. Wineconsole however actually properly emulates a console window (best when running --backend=curses, else X will try to start still).

Ah, that explains a lot, thanks
I still get issues about it wanting to start a window. It's less important now as my console gets taken over correctly. It's weird, and I would almost say that it's a configuration issue on my side now (I recompiled a fresh version of wine without X11 support).

Its to a point now that the "Cannot create display" errors don't affect anything functionally (where before they wouldn't let my server even start), so I'm content with seeing a few error messages appear on server init.

Thank you very much with this effort It's much appreciated

(I changed my sig BTW).
These are some awesome news, perhaps I'll finally be able to host a LFS server I gave it a brief test on my headless openSUSE server and it worked like a charm, so it definitely doesn't need a running X server.
Um, teeny hop skip and jump from here to native linux dedi?
(My hosting a/c doesn't have Wine... Quick search failed to find official "no" on native linux version.)
Quote from Neilser :Um, teeny hop skip and jump from here to native linux dedi?
(My hosting a/c doesn't have Wine... Quick search failed to find official "no" on native linux version.)

It would be insanely great to have a UNIX version on the dedi one day, but I guess it would mean a complete rewrite of the current implementation. Supporting the myriad of *NIX systems out there would itself be a massive undertake I for one think it's perfect that we can run the dedi on X-less machines and still get the output.
Quote from dawesdust_12 :
Its to a point now that the "Cannot create display" errors don't affect anything functionally (where before they wouldn't let my server even start), so I'm content with seeing a few error messages appear on server init.

Funny enough I now also see those errors with wine-1.4.1-1.el6.x86_64
Quote from cargame.nl :Funny enough I now also see those errors with wine-1.4.1-1.el6.x86_64

Are you sure there aren't the warnings related to WINE setup tools which are run after WINE's first installation or an update? These tools have a GUI but they are not necessary for WINE's operation.
No, I'm sure.

But I think LFS dedi wants to make a sound? Server can't do that because there is no sound card and want to display an error message?

ALSA lib seq_hw.c:457:(snd_seq_hw_open) open /dev/snd/seq failed: No such file or directory
Application tried to create a window, but no driver could be loaded.
Make sure that your X server is running and that $DISPLAY is set correctly.

Sound wouldn't rely on X though.

It is bizzare that newer versions of wine have issues with the X server in headless mode.
Hmm no never mind all of this. I just realize I still had test1 ... test2 is clean
Weird. Test 2 still gives me some stuf. I'll double check later and repull test2 to verify.
Quote from dawesdust_12 :You could always have colours in console. The Windows CMD does allow you to do this. PRISM implements it AFAIK too.

We kinda do yes, but it's only on the Linux side I'm afraid.

Quote from dawesdust_12 :my intent is to get a proper server running, that will start with init.d and everything as part of boot.

That would be the holy grail.

Quote from Scawen :From a quick look, I can't see how to do colour. How to do it seems to depend on where the output is going. I can only see how to do colour on Linux consoles, not Windows.

Welcome to the club Scawen, we have jackets. If you want to see an application that is Open Source that does use colored text inside of the command application on Windows take a look at git. Myself and Victor (Yes, that Victor, your fellow developer-at-arms.) use Git on the PRISM project that we share programming duties on. It impalements color within the windows command prompt some how without resorting to some crazy trickery. I recomend you take a dive into their source code and see how they did that.

If you can make heads or tails of their C code, your best best is ... color.h and color.c. I'm sure you can deraive your own color mechanism from there.
Quote from Dygear :That would be the holy grail.

Can already be done, even with the conventional dedi. If people are finding it difficult I'm more than happy to share the sysvinit script I've got working.. (it depends and uses start-stop-daemon, but you could easily wrap it with the equivilent for whatever your preferred distro is, if that's unavailable)
I need to get around to doing all that stuff.. not that I restart my server very often. I am the laziest person in the world for it.. my web server doesn't even start up if my server reboots.. gotta do it manually :P
Quote from dawesdust_12 :I need to get around to doing all that stuff.. not that I restart my server very often. I am the laziest person in the world for it.. my web server doesn't even start up if my server reboots.. gotta do it manually :P

That's insane, all you have to do is add something to the cron tab like
@reboot start program

But we are pretty far off topic here.

Any luck with the color problem Scawen? Also if you want some inspiration, take a look at what Victor did with the telnet module in PRISM. That stuff is pure gold.
A proper server wont need a restart -ever-. This is the best scoring server on that matter in my case;
Quote :Uptime: 905 days(!), 22:51:07



--

And I thought I've read that Scawen don't want to spend time on making colored text. His wanted to achieve goals are on post #1 :somerandomflowersmiley:


.
Quote from cargame.nl :A proper server wont need a restart -ever-. This is the best scoring server on that matter in my case;

Kernel updates? :P We're not all rich people who can afford to pay Oracle for Ksplice
Linux is not Windows. Needed updates can be installed without reboot. Kernel updates could be done, but I personally install them rarely. Once per year, sometimes once per 2-years. Server should work constantly.
Quote from misiek08 :Once per year, sometimes once per 2-years.

Personally I judge on the changelog and release notes. For instance like hell am I going to continue running a kernel with a known remote code execution in it - even if its firewalled, whats the point in increasing the risk? We're all human and make mistakes from time to time

Quote from misiek08 :Server should work constantly.

That's what clustering is for Admittedly in the case of LFS that's a little tricker, but security > uptime, imho.
Quote from the_angry_angel :Kernel updates? :P We're not all rich people who can afford to pay Oracle for Ksplice

For Ubuntu and Fedora, KSplice is free...
1
This thread is closed

Console Dedicated Host TEST 2
(30 posts, closed, started )
FGED GREDG RDFGDR GSFDG