B4J Question VPS requires a password

derez

Expert
Licensed User
Longtime User
Launching a server application on linux requires me to key my password. If I use nohup like here
B4X:
nohup path_to_java/bin/java -jar somejar.jar > nohup.out &
the application is not launched, probably waiting for the password.
For the same reason I can't launch it automatically at startup.
How do I go around this ?

I try not to use sudo but without it the database file cannot be open.
Edit: If I change to superuser then no need for password !
 
Last edited:

codie01

Active Member
Licensed User
Longtime User
Is this a database issue? I can not see it would be an issue with starting the app. The fact you say "without it the database file can not open"

Check the following:

1. Have you setup a user for the database and given all privileges.
2. Is your app using the user you setup in (1)
3. It maybe that the ip you are using to access in is refused. In this case you need to go to remoteSQL and setup wild card access %

Phil
 
Upvote 0

derez

Expert
Licensed User
Longtime User
Create an init.d script or simply put the command in /etc/rc.local. It works on Debian.
There is no rc.local file in mint anymore - it was deprecated...
So now there are two option to launch the application:
1. change to su, change to the folder of the program, run with nohup, can close the terminal.
2. change to the folder of the program, run with sudo and without nohup, keep the terminal open.
 
Upvote 0

derez

Expert
Licensed User
Longtime User
Is this a database issue? I can not see it would be an issue with starting the app. The fact you say "without it the database file can not open"

Check the following:

1. Have you setup a user for the database and given all privileges.
2. Is your app using the user you setup in (1)
3. It maybe that the ip you are using to access in is refused. In this case you need to go to remoteSQL and setup wild card access %

Phil

The database is used by the b4j server program. Everything works fine if I use sudo or su but both options require entering password in order for launching the server as explained above.
 
Upvote 0

derez

Expert
Licensed User
Longtime User
You are correct rc.local is deprecated. You need to use systemd

This link is the best guide I can find that take you through the whole process of create a service with systemd. https://medium.com/@benmorel/creating-a-linux-service-with-systemd-611b5c8b91d6
Read it, looks promising for the auto start, I still don't know how to eliminate the requirement for password every time it runs.
I read somewhere that rc.local is run before the system changes to the user , still as root.
Will the service do the same ? like this:
Typically you instruct systemd to run a service as a specific user/group with a User= and Group= directive in the [Service] section of the unit file.

Set those to root (or remove them, as running as root is the default).
 
Last edited:
Upvote 0

derez

Expert
Licensed User
Longtime User
Problem solved. This is how:
1. created a service in systemd as explained here https://www.linuxbabe.com/linux-server/how-to-enable-etcrc-local-with-systemd
2. I put my program in a directory in /etc (using nemo) and referenced it in the rc.local file (which was created in 1).
For some reason the path to Home/dudu was not recognized by the service, maybe because the user account does not exist when the service is run.
Now it is launched automatically in boot.
 
Last edited:
Upvote 0
Top