This question involves a raspberry pi 4 connected via Wifi to the internet, and running a SpringBoot app that generates a file tree with special values upon user request. The SpringBoot App needs compute the parent path of some files located on the remote server to build the file tree the user has asked.
This all works when the remote data are already mounted when the SpringBoot app is launched from a console.
As I need the SpringBoot app to run automatically and be launched at boot time I changed /etc/rc.local
and /etc/fstab
like this :
In /etc/rc/local
I added su pi -c 'cd /home/pi/MyApp && ./LaunchApp.run &'
and in /etc/fstab
I added
myUser@ftp.remote.server.com: /home/pi/projects/remoteData fuse.sshfs port=22,user,identityfile=/home/pi/.ssh/id_rsa,noatime,allow_other
Mind the allow_other
so that all user can read and write (not only root), and the path to the ssh key to use.
However the SpringBoot app does start but then it cannot access to the remote data so the file tree cannot be build. If I login via VNC (GUI login), then I am able to click on the mount point which actually mounts and the SpringBoot app can compute the file tree because it can access to the remote data.
But when I close VNC (even without disconnecting from the logged in user) the SpringBoot App cannot access to the remote data anymore.
Running sudo mount -av
(or -fav
to simulate the mount) in a console led to the mounting of the remote data and the ability for SpingBoot to access to the remote data as expected. But after log out no access to the remote data is possible.
Please note that I tested the fstab command with and without _netdev
but it did not change anything regarding the ability for the SpringBoot app to access the remote data.
I also ran ps -A
to check which user was running SpringBoot and it showed pi
.
Consequently I am wondering why the SpringBoot app can only see the remote data when pi user is connected ?
And furthermore what can I do to make the mount point available to the SpringBoot app without having to manually mount the remote data ?
Please note : I also tried to launch the mounting from rc.local
or from ~/.profile
(in both cases removing the corresponding line from fstab
) by adding this line :
rc.local
su pi -c 'sshfs myUser@ftp.remote.server.com: /home/pi/projects/remoteData &'
or .profile
sshfs myUser@ftp.remote.server.com: /home/pi/projects/remoteData
Still SpringBoot was not able to access to the remote data unless I manually log in.
Any help much appreciated