![](https://git.hkwtc.org/TC/fsexec/raw/master/title.png)
# fsexec

ArOZ Online System File Explorer - Freeze Script Execution Application, design for replacing those script that was freezing the system while file IO.

## What is Freeze Script Execution Application?
Freeze Script Execution Application - Short for fsexec, is a binary written in golang to replace the old scripts in the ArOZ Online File System that would freeze the whole PHP server during file IO operations.
This script make use of golang's super fast IO and processing ability and make file operation much faster on the new implementation.

The fsexec application will receive the command as two parts. In most case, you will be using these funcitons only.

./fsexec {uuid} {command}

where command is a string in base64 encoded JSON string.

## So, how can I use this binary?

For example, you want to use the funciton [copy] with paramter {source} and {target}.

First, you need to convert the command into an array and parse it as JSON string.

For example, you have the following command array:
```
["copy","./test.txt","target/test.txt"]
```
Next, you would want to stringify it as JSON string.
```
"[\"copy\",\"./test.txt\",\"target/test.txt\"]"
```
Then, you can convert the string above into base64 representation. This is what you will get:
```
WyJjb3B5IiwiLi90ZXN0LnR4dCIsInRhcmdldC90ZXN0LnR4dCJd
```
Lastly, you call the fsexec with the following command. Assumeing the {uuid} is [123]
```
./fsexec 123 WyJjb3B5IiwiLi90ZXN0LnR4dCIsInRhcmdldC90ZXN0LnR4dCJd
```

Here are some examples:
```
# copy test.txt test/test.txt
./fsexec uuid_string WyJjb3B5IiwidGVzdC50eHQiLCJmb2xkZXIvdGVzdC50eHQiXQ==

# copy_folder test/ target/test/
./fsexec uuid_string WyJjb3B5X2ZvbGRlciIsInRlc3QvIiwidGFyZ2V0L3Rlc3QvIl0=
```
The fsexec application will create a folder named "log" if it doesn't exists.
Inside the log folder, you would found "done" and "error" sub-folders. In simple words:

- For all successfully finished file operation, its log will be stored in "done" directory.
- For all failed file operation, its log will be stored in "error" directory.
- For all processing file operation, its log will be stored under "log/" directory but not its subfolders.

## What is UUID then?
As its name suggest, UUID is a unique string or interger that can be used to identify each file operations. 
You can use anything you want as soon as it is unique. Just to make sure don't use some wierd, not universal-supported characters.

## License
CopyRight Author Toby Chui under ArOZ Online Project, 2019

