How's API-support going?

#1
In our project, we're going to let each operator run on different port and maybe IP aswell.
Like,
if operator = foo => call localhost:8080
if operator = bar => call localhost:9090

I think this is rather simple for OLS to handle, just adding a virtual host and listener right?

But we don't want to administer this through the OLS GUI, and i was checking your API section in the Wiki, it was rather empty :).
So, is there some APIs defined? :)
 

lsfoo

Administrator
#2
Hi Enthess,

I'm not sure if I understand you correctly. Is an "operator" an External App? So you are trying to set up a listener/virtual host for each ext app?

If this is the case, are you asking about how to set up a vhost and listener through the command line?

We do have an API that allows users to create their own handlers (in C, hooking into the server state machine). It is currently still in a beta form, but it is there if needed. If this is what you're looking for, I can elaborate further on this as well.
 
#3
Hi,

Yeees... I'd like to call it like a "realm". Its going to co-op with MySQL database too.
What we're looking for is to make a script that says "./addOperator <name> <ip> <port> <dbIp> <dbPort> etc etc etc" And that script will fire up an External App as you call it, that listens to ip and port and restarts the webserver to activate it.

Although, i dont know C-programming :(.
 

lsfoo

Administrator
#4
This sounds like more the first case rather than the second case (so no need for C programming :))

All/any changes made in the web admin GUI can also be done in the command line by editing the configuration files.

First of all, apologies for the wall of text. I tried to lay out the steps needed to be done, but hopefully the steps are clear enough.

First, I suggest making a backup of all your configuration files (as this is scripting, we don't want to accidentally delete all your settings ;))

Changes that need to be made:
** These first three steps should be do-able in ~4-5 lines of script. It's basically all 'mkdir' calls.

1. Create a vhost root. Normally, this is a subdirectory inside your lsws install
e.g.
Code:
lsws/Example
2. Inside the vhost root, you may want to create an html sub directory and a logs subdirectory depending on your preferred settings.
3. Create a vhost conf directory. Normally, this is a subdirectory inside your conf directory
e.g.
Code:
lsws/conf/vhosts/Example/
for the Example virtual host

** The next three steps are for creating a virtual host.

4. Try creating your sample virtual host via web gui using the directories you just created
So, setting your vhost root to
Code:
$SERVER_ROOT/Example
vhost document root to
Code:
$SERVER_ROOT/Example/html
etc.
5. Check out the conf file that was created for your virtual host. You should be able to use this as a template file for your script.
6. Also check out the virtualHost entry for your newly created virtual host in
Code:
lsws/conf/httpd_config.conf
. This can be used as a template for your script to append to the file.

** The next three steps are for creating a listener and mapping it to the above virtual host.

7. In the gui, create a sample listener. After creating the listener and saving it, remember to add a vhost map to map the listener to the vhost created above.
8. Restart the server and make sure that the listener and vhost work.
9. Check out the listener entry for your newly created listener in
Code:
lsws/conf/httpd_config.conf
This can be used as a template for your script to append to the file.

At the end of the above steps, you should have:
- 1 new vhost root directory with a logs directory and a html directory and anything else that you may need.
- 1 new vhost conf directory.
- 1 new conf file in the above vhost conf directory.
- 2 new entries in your httpd_config.conf file.

As mentioned above, creating the directories is simply a few mkdir calls.
You can use the vhost conf file as a template to create a new conf file for each additional operator's virtual host.
You can also use the entries in the server conf file to append to the server conf file for your operators.

In the end, this should be do-able without too many lines of script, obviously depending on how complex you want to make it and how much error checking you want to do.

Hope this helps! Again, sorry for the wall of text, do let me know if you have any questions about this.
 
#5
@lsfoo
Thanks for your wall of text, i will print it out, i will just add 50 papersheets in my printer! ;).

You mention some script, but i dont see any script? Did you forget to add it perhaps? :)
About point 7. Is this not possible to do textbased?

Dont worry about configurations, i will probably fire up an extra machine and experiment on that one :)
 

lsfoo

Administrator
#6
Not sure if 50 will be enough :D

I was more referring to you being able to create your own script.

The first set of instructions are probably each their own line of script.

The three steps for creating a vhost are so you can create a template file. You can then use cp to duplicate the file where you want it (as you mentioned, via script arguments), and sed to correct the specifics (any directories that may need to change, etc)

The last three steps are so you know what gets added to the server configuration file when you create a listener and map it to the vhost. Doing it once via gui allows you to know exactly what you can copy via command line. This could end up being simply an append.

Of course, you'll then have to restart the server. Restarting can be done in your script as well, via
Code:
service lsws restart
or if that doesn't work,
Code:
/path/to/lsws/bin/lswsctrl restart
If you run into any problems when creating your script, I'd be happy to give pointers. Unfortunately, I'm a bit busy, so I won't be able to create the script.
 
#7
@lsfoo

Thanks, then i understood correctly, i also thought that your post was more "pointers into the script" in how to make it.

I will ask if there's anything that troubles, but your post was quite descriptive.

Thanks! :)
 
Top