root / Server / cedserver.lpr @ 157:0b95089e72d4
History | View | Annotate | Download (2 kB)
| 1 | (* |
|---|---|
| 2 | * CDDL HEADER START |
| 3 | * |
| 4 | * The contents of this file are subject to the terms of the |
| 5 | * Common Development and Distribution License, Version 1.0 only |
| 6 | * (the "License"). You may not use this file except in compliance |
| 7 | * with the License. |
| 8 | * |
| 9 | * You can obtain a copy of the license at |
| 10 | * http://www.opensource.org/licenses/cddl1.php. |
| 11 | * See the License for the specific language governing permissions |
| 12 | * and limitations under the License. |
| 13 | * |
| 14 | * When distributing Covered Code, include this CDDL HEADER in each |
| 15 | * file and include the License file at |
| 16 | * http://www.opensource.org/licenses/cddl1.php. If applicable, |
| 17 | * add the following below this CDDL HEADER, with the fields enclosed |
| 18 | * by brackets "[]" replaced with your own identifying * information: |
| 19 | * Portions Copyright [yyyy] [name of copyright owner] |
| 20 | * |
| 21 | * CDDL HEADER END |
| 22 | * |
| 23 | * |
| 24 | * Portions Copyright 2008 Andreas Schneider |
| 25 | *) |
| 26 | program cedserver; |
| 27 | |
| 28 | {$mode objfpc}{$H+}
|
| 29 | |
| 30 | uses |
| 31 | {$IFDEF UNIX}{$IFDEF UseCThreads}
|
| 32 | cthreads, |
| 33 | {$ENDIF}{$ENDIF}
|
| 34 | SysUtils, UConfig, UCEDServer; |
| 35 | |
| 36 | {$I version.inc}
|
| 37 | |
| 38 | {$IFDEF WINDOWS}{$R cedserver.rc}{$ENDIF}
|
| 39 | |
| 40 | begin |
| 41 | Writeln('');
|
| 42 | Writeln('CentrED Server Version ', ProductVersion);
|
| 43 | Writeln('Copyright ', Copyright);
|
| 44 | //Writeln('================================');
|
| 45 | Writeln('');
|
| 46 | |
| 47 | {$IFDEF Windows}
|
| 48 | if FileExists(ConfigFile) then |
| 49 | Config := TConfig.Create(ConfigFile) |
| 50 | else |
| 51 | Config := TConfig.Init(ConfigFile); |
| 52 | {$ELSE}
|
| 53 | if ParamStr(1) = '--init' then |
| 54 | Config := TConfig.Init(ConfigFile) |
| 55 | else if FileExists(ConfigFile) then |
| 56 | Config := TConfig.Create(ConfigFile) |
| 57 | else begin |
| 58 | Writeln('No valid config file was found. Use --init to create one.');
|
| 59 | Halt; |
| 60 | end; |
| 61 | {$ENDIF}
|
| 62 | |
| 63 | Writeln(TimeStamp, 'Initialization started'); |
| 64 | Randomize; |
| 65 | CEDServerInstance := TCEDServer.Create; |
| 66 | Writeln(TimeStamp, 'Initialization done'); |
| 67 | CEDServerInstance.Run; |
| 68 | Write(TimeStamp, 'Shutting down ... '); |
| 69 | FreeAndNil(CEDServerInstance); |
| 70 | Config.Flush; |
| 71 | FreeAndNil(Config); |
| 72 | Writeln('done');
|
| 73 | end. |
| 74 |