How to update symlink location without restarting?

#1
Hi,

How can I force OLS to follow symlink location even when the location changes without restarting the service?

This is the app structure:
document root: /srv/app/www/current
current is a symlink to /srv/app/www/releases/XXXXXX

Everytime the client do a deploy, XXXX value changes:

Code:
lrwxrwxrwx 1 atencil atencil    39 Nov 26 17:42 current -> /srv/app/www/releases/1574800921
drwxrwxr-x 5 atencil atencil  4096 Nov 26 17:42 releases
Code:
root@ip-45-33-5-59:/srv/app/www# ls -l releases/
total 12
drwxrwxr-x 14 atencil atencil 4096 Nov 26 17:41 1574800904
drwxrwxr-x 14 atencil atencil 4096 Nov 26 17:41 1574800917
drwxrwxr-x 14 atencil atencil 4096 Nov 26 17:42 1574800921
The problem is OLS continue to follow to the old location, in this example, 1574800917. I enabled debug and this is the line showing OLS is searching for the file in the wrong location:

2019-11-26 17:42:24.245871 [DEBUG] [127.0.0.1:59178] (stat)File not found [/srv/app/www/releases/1574800917/teste.php].


Thanks! :D
 

lsqtwrk

Administrator
#2
hmmmm

I just ran a test, it seems work fine on me


Code:
[root@test my.domain.com]# ls -l
total 12
drwxr-x--- 2 root    nobody  4096 Nov 26 10:00 logs
lrwxrwxrwx 1 domainu domainu   18 Nov 27 10:30 public_html -> public_html_origin
drwxr-xr-x 2 domainu domainu 4096 Nov 27 10:32 public_html_2
drwxr-xr-x 2 domainu domainu 4096 Nov 27 10:34 public_html_origin
[root@test my.domain.com]# ls
logs  public_html  public_html_2  public_html_origin
[root@test my.domain.com]# curl http://my.domain.com/test.html
test
[root@test my.domain.com]# ls -l
total 12
drwxr-x--- 2 root    nobody  4096 Nov 26 10:00 logs
lrwxrwxrwx 1 domainu domainu   18 Nov 27 10:30 public_html -> public_html_origin
drwxr-xr-x 2 domainu domainu 4096 Nov 27 10:32 public_html_2
drwxr-xr-x 2 domainu domainu 4096 Nov 27 10:34 public_html_origin
[root@test my.domain.com]# echo "" > ./public_html_origin/test.html
[root@test my.domain.com]# echo "test file" > ./public_html_origin/test.html
[root@test my.domain.com]# curl http://my.domain.com/test.html
test file
[root@test my.domain.com]# echo "test file2" > ./public_html_2/test.html
[root@test my.domain.com]# rm -rf public_html
[root@test my.domain.com]# ln -s public_html_2 public_html
[root@test my.domain.com]# ls -l
total 12
drwxr-x--- 2 root    nobody  4096 Nov 26 10:00 logs
lrwxrwxrwx 1 root    root      13 Nov 27 10:35 public_html -> public_html_2
drwxr-xr-x 2 domainu domainu 4096 Nov 27 10:35 public_html_2
drwxr-xr-x 2 domainu domainu 4096 Nov 27 10:34 public_html_origin
[root@test my.domain.com]# curl http://my.domain.com/test.html
test file2
please correct me if I did anything wrong

basically I used public_html_origin to link it first , to public_html , then remove it and link to public_html_2
 
#3
Hm... I will do some more tests here.

But just to know, what version are you using?
And can you show me your symlink conf on OLS? I think they are on httpd.conf
 

lsqtwrk

Administrator
#4
Hi,

I just installed from 1.6.4 binary , nothing is changed from default conf , only set up the listener with Example vhost , nothing more is touched.
 
#5
That's super weird... I just got a new server to test, installed OLS 1.5.9 at first, then I tried 1.6.4 binary as well, and still the symlink doesn't update. Default Example vhost used, nothing modified:

Code:
root@li965-219:/usr/local/lsws/Example# ls -la
total 28
drwxr-xr-x  7 root root 4096 Nov 27 19:53 .
drwxr-xr-x 22 root root 4096 Nov 27 19:28 ..
drwxr-xr-x  2 root root 4096 Nov 27 19:28 cgi-bin
drwxr-xr-x  2 root root 4096 Nov 19 20:03 fcgi-bin
lrwxrwxrwx  1 root root   13 Nov 27 19:53 html -> html_current/
drwxr-xr-x  2 root root 4096 Nov 27 19:50 html_2
drwxr-xr-x  6 root root 4096 Nov 27 19:49 html_current
drwxr-xr-x  2 root root 4096 Nov 27 19:28 logs
root@li965-219:/usr/local/lsws/Example# cat html_current/teste.html
teste
root@li965-219:/usr/local/lsws/Example# cat html_2/teste.html
teste2
root@li965-219:/usr/local/lsws/Example# curl http://45.33.11.219:8088/teste.html
teste
root@li965-219:/usr/local/lsws/Example# rm -rf html
root@li965-219:/usr/local/lsws/Example# ln -s html_2/ html
root@li965-219:/usr/local/lsws/Example# curl http://xxxxxxxxxxx:8088/teste.html
teste
root@li965-219:/usr/local/lsws/Example# curl http://xxxxxxxxxxx:8088/teste.html
teste
root@li965-219:/usr/local/lsws/Example# curl http://xxxxxxxxxxx:8088/teste.html
teste
root@li965-219:/usr/local/lsws/Example# systemctl reload lsws
root@li965-219:/usr/local/lsws/Example# curl http://xxxxxxxxxxx:8088/teste.html
teste2
Tested this on Ubuntu 16.04 LTS and Ubuntu 18.04 LTS.

This seems to happen only when using the symlink as Document Root. If the symlink is created inside the root directory, the symlink updates as expected.
 

lsqtwrk

Administrator
#6
I just tried again with 1.6.4

Code:
root@test:/usr/local/lsws/Example# mkdir html_2
root@test:/usr/local/lsws/Example# mkdir html_3
root@test:/usr/local/lsws/Example# echo "test2" > ./html_2/index.html
root@test:/usr/local/lsws/Example# echo "test3" > ./html_3/index.html
root@test:/usr/local/lsws/Example# rm -rf html
root@test:/usr/local/lsws/Example# ln -s html_2 html
root@test:/usr/local/lsws/Example# ls -l
total 20
drwxr-xr-x 2 root   root    4096 Nov 27 13:53 cgi-bin
drwxr-xr-x 2 nobody nogroup 4096 Nov 27 13:53 fcgi-bin
lrwxrwxrwx 1 root   root       6 Nov 27 13:57 html -> html_2
drwxr-xr-x 2 root   root    4096 Nov 27 13:57 html_2
drwxr-xr-x 2 root   root    4096 Nov 27 13:57 html_3
drwxr-xr-x 2 nobody nogroup 4096 Nov 27 13:54 logs
root@test:/usr/local/lsws/Example# curl -XGET http://domain.com/index.html
test2
root@test:/usr/local/lsws/Example# rm -rf html
root@test:/usr/local/lsws/Example# ln -s html_3 html
root@test:/usr/local/lsws/Example# curl -XGET http://domain.com/index.html
test3

I DM'ed you a test server, please try if you can reproduce the issue there.
 
#7
For future reference: Fixed in version 1.5.10
  • [Bug Fix] Fixed the old destination for a symlink directory being used when serving static files even after the symlink has been changed to a new location.
 
Top