Author Topic: Sharing a file beetween two solservers on same pc  (Read 2502 times)

0 Members and 1 Guest are viewing this topic.

Offline Silnikos

  • Soldier
  • **
  • Posts: 129
Sharing a file beetween two solservers on same pc
« on: January 15, 2011, 08:56:58 am »
Is there any way to make two scripts running in two soldatserver on same pc access one file?

/sol/solserv1/soldatserver
/sol/solserv2/soldatserver

Are these able to access
/sol/something.txt ?
« Last Edit: January 15, 2011, 02:04:03 pm by Silnikos »

Offline Furai

  • Administrator
  • Veteran
  • *****
  • Posts: 1908
    • TransHuman Design
Re: Sharing a file beetween two solservers on same pc
« Reply #1 on: January 15, 2011, 08:59:25 am »
Under windows or linux?
"My senses are so powerful that I can hear the blood pumping through your veins."

Offline Silnikos

  • Soldier
  • **
  • Posts: 129
Re: Sharing a file beetween two solservers on same pc
« Reply #2 on: January 15, 2011, 09:03:08 am »
linux

Offline zakath

  • Inactive Soldat Developer
  • Veteran
  • ******
  • Posts: 1224
    • Soldatladder
Re: Sharing a file beetween two solservers on same pc
« Reply #3 on: January 15, 2011, 09:05:29 am »
cd /sol/solserv1/
ln /sol/something.txt
cd /sol/solserv2/
ln /sol/something.txt
then both will have access to somethin.txt directly in their soldatserver dir.

#soldat.mapping - #soldat.inc - #soldatladder - #soldat.gather.nordic

Offline Silnikos

  • Soldier
  • **
  • Posts: 129
Re: Sharing a file beetween two solservers on same pc
« Reply #4 on: January 15, 2011, 01:09:22 pm »
cd /sol/solserv1/
ln /sol/something.txt
cd /sol/solserv2/
ln /sol/something.txt
then both will have access to somethin.txt directly in their soldatserver dir.
But is there any way to use it trough script?
Let's say I use the same script in both servers: let's say it save all the playernames into /database/playername.txt onjoin - if the file already exists, it reads the file and adds +1 to the integer stored in file. How would that look? I mean, I'm not able to do "ln filename" since the new files are being created all the time.

Offline Furai

  • Administrator
  • Veteran
  • *****
  • Posts: 1908
    • TransHuman Design
Re: Sharing a file beetween two solservers on same pc
« Reply #5 on: January 15, 2011, 01:43:06 pm »
As far as I know jrgp got it to work with web gather. All servers use one folder with scripts, maps etc...I guess you should ask him or wait until he replies inhere.
"My senses are so powerful that I can hear the blood pumping through your veins."

Offline SyavX

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 338
Re: Sharing a file beetween two solservers on same pc
« Reply #6 on: January 15, 2011, 02:56:00 pm »
Ok, once again...
At the moment you have something like this:
Code: [Select]
/sol/solserv1/soldatserver/scripts/your_script/database/playername.txt
/sol/solserv2/soldatserver/scripts/your_script/database/playername.txt

Copy "playername.txt" into /sol
You will have:
Code: [Select]
/sol/playername.txt
Then do:
Code: [Select]
# this will change current directory
cd /sol/solserv1/soldatserver/scripts/your_script/database
# this will remove the "playername.txt" file from current directory
rm playername.txt
# this will create link to "/sol/playername.txt" in current directory
ln /sol/something.txt

Do the same with /solserv2

You will have:
Code: [Select]
/sol/playername.txt
and
/sol/solserv1/soldatserver/scripts/your_script/database/playername.txt
/sol/solserv2/soldatserver/scripts/your_script/database/playername.txt

Now all 3 "playername.txt" files are hardlinked and both scripts (from /solserv1 or /solserv2) will have access and will edit the same content of "playername.txt".

BUT I'm afraid you will get an arror in case of writing to this file by both servers at the same time. This kind of links will help you to store and have access to static settings but they couldn't be a replacement for database with multy-connections...
« Last Edit: January 15, 2011, 03:01:11 pm by SyavX »

Offline Silnikos

  • Soldier
  • **
  • Posts: 129
Re: Sharing a file beetween two solservers on same pc
« Reply #7 on: January 15, 2011, 03:12:36 pm »

Now all 3 "playername.txt" files are hardlinked and both scripts (from /solserv1 or /solserv2) will have access and will edit the same content of "playername.txt".

BUT I'm afraid you will get an arror in case of writing to this file by both servers at the same time. This kind of links will help you to store and have access to static settings but they couldn't be a replacement for database with multy-connections...
kewl but unless you can do the same with whole directories this is not a solution for me since the files are being created all the time so I cannot hardlink them manually.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Sharing a file beetween two solservers on same pc
« Reply #8 on: January 15, 2011, 03:32:14 pm »
Here are a few options that I can see:

(1) Hard-linking
Hard-linking is probably the easiest method of them all, if it can be done. I'm not very experienced with hard-linking itself, but I have played with it before successfully, and is definitely a possibility.

(1.1) Hard-linking files
Every file that needs to be accessed can be hard-linked. If a new file is created that needs to be accessed by multiple servers, it needs to be hard-linked. This can be done by hand (when dealing with low quantity of files), or automatically (separate application, or Soldat Server script). If the Soldat Server is to do the hard-linking, it is possible for it to use shell_exec, although safe-mode must be disabled. I would like to note that shell_exec can sometimes be a pain, as I believe a trick or something needs to be done in order to have it behave as command line (or the linux equivalent) does.

+ No external application
+ No connections
- Every new file created that needs to be accessed must be hard-linked
- Safe-mode must be disabled for script automatically hard-link
- Different methods for hard-linking may be necessary for different OSs
- Requires file access (generally only single or networked computers)

(1.2) Hard-linking directories
Simply hard-link the directory that contains all the files and sub-directories that need to be accessed. This allows for multiple files to be easily accessed, and even when new files are made in addition, nothing needs to be done in order for them to be accessed.

I've been using this method for a while now for using script files that are shared throughout different scripts, servers, and projects in general. In order to create the hard-link of a directory, a long time ago I made this .bat file:
Code: [Select]
linkd "shared" "C:/[hidden]/shared"
pause
It creates the directory named "shared" that is hard-linked to the directory "C:/[hidden]/shared". This works for me on Windows 7/XP. I'm sure linux has something similar to this.

+ No external application
+ No connections
- Different methods for hard-linking may be necessary for different OSs
- Requires file access (generally only single or networked computers)

(2) External application connection
This is the main concept that is going to be used in SGAS (option 3). There is an external application which behaves as the relayer which will relay and redirect information to where it belong. The main advantages of this is that it allows for multiple computers to host severs, and having them share information. For having a database of information, it is also possible to store it at the external application's location, and when the Soldat Servers access it, they contact the external application.

(2.1) External application connection via Sockets
The connection is made via socket use, which generally requires use of threading. Despite how threading is generally frowned upon, many people do not have very many difficulties with it, and makes this for a very valid method, depending if your server can handle threading well or not.

+ Multiple computers have access
- Instability of threading necessary for socket use
- (Claimed) instability of sockets (I've never had an issue)
- Need to create and host an external application

(2.2) External application connection via Admin Client
The connection is made via admin port connection. In my opinion, this is the most dynamic option that does not sacrifice stability, although for the purpose of a single computer, hard-linking may be a better option.

CurryWurst has created an interesting example using this idea, and may be found at Exploiting a Soldat Server as TCP Socket Server. Feel free to use that as a reference, guide, or whatever if you wish to.

+ Multiple computers have access
- Admin port is spammed with information (can be made to be filterable)
- Need to create and host an external application

(3) Soldat Global Account System (SGAS)
My favorite of them all, SGAS! SGAS is a unified method that will provide players with accounts, scripts with access to a global database, and scripts with access to communication to other servers (and applications). Basically, it extends scripting. It is currently in development, team including CurryWurst, Boblekonvolutt, myself, and others.

+ Multiple computers have access
+ No need to fuss with how it happens (SGAS does all the backbone dirty work)
+ Easy to install and use
- Incomplete currently (completion may be further in the future than you would like)
« Last Edit: March 09, 2013, 11:41:07 am by DorkeyDear »

Offline Polifen

  • Soldier
  • **
  • Posts: 127
Re: Sharing a file beetween two solservers on same pc
« Reply #9 on: January 17, 2011, 02:53:50 am »
If you're the owner of the whole server you could use Shell_Exec to copy file from sol1 to sol2 and vice versa after any change, or you could use Shell_Exec to link new files.

Offline jrgp

  • Administrator
  • Flamebow Warrior
  • *****
  • Posts: 5037
Re: Sharing a file beetween two solservers on same pc
« Reply #10 on: January 17, 2011, 04:00:43 am »
Just saw this topic.

(1.2) Hard-linking directories
Simply hard-link the directory that contains all the files and sub-directories that need to be accessed. This allows for multiple files to be easily accessed, and even when new files are made in addition, nothing needs to be done in order for them to be accessed.

Under Unix/Linux, hard links can not refer to directories; you will need to use symbolic links.

joe@adore:/tmp$ touch file
joe@adore:/tmp$ ln file file2
joe@adore:/tmp$ echo tits > file
joe@adore:/tmp$ cat file2
tits
joe@adore:/tmp$ rm file file2
joe@adore:/tmp$ mkdir funstuff
joe@adore:/tmp$ ln funstuff funstuff2
ln: `funstuff': hard link not allowed for directory
joe@adore:/tmp$ ln -s funstuff funstuff2
joe@adore:/tmp$ touch funstuff/stuffthatsfun
joe@adore:/tmp$ ls funstuff2/
stuffthatsfun
joe@adore:/tmp$


As far as I know jrgp got it to work with web gather. All servers use one folder with scripts, maps etc...I guess you should ask him or wait until he replies inhere.

For that I have one folder, master/, which contains maps/, scenery-gfx/, scripts/, textures/, and the soldatserver executable. Each gather server is in a separate folder, with the files/folders I just mentioned symlinked to those in master/.
« Last Edit: January 17, 2011, 04:05:07 am by jrgp »
There are other worlds than these

Offline Silnikos

  • Soldier
  • **
  • Posts: 129
Re: Sharing a file beetween two solservers on same pc
« Reply #11 on: January 17, 2011, 06:40:25 am »
Under Unix/Linux, hard links can not refer to directories; you will need to use symbolic links.
Yes, that's exactly what I needed. Got it working, thanks!