PLCnext on LinkedInPLCnext on Instagram  PLCnext on YouTube Github PLCnext CommunityStore PLCnext Community

  1. jbals
  2. PLCnext Store
  3. Wednesday, 22 January 2020

I am developing a plcnext app as linux daemon with a custom init.d script. The init.d script calls a shell script which starts a java program via "exec". The PID of the java program which was started is stored within a file in the folder "/tmp".

When I start the app via the WBM I can see that the PID file is generated in the tmp folder. But the process ID contained in the PID file is no longer running. Which means that the app is not running.

When I call the init.d script in "/etc/init.d" with the parameter "start" everything works fine. Are there any restrictions for the init.d script? Do I have to use anything else than "exec" to make sure that a new process is created for the java program?

Martin PLCnext Team Accepted Answer Pending Moderation
0
Votes
Undo

Hello,

Are the shell script (the one called by the init.d script) and the java program both packaged with the app?

~ Martin.

Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support

  1. more than a month ago
  2. PLCnext Store
  3. # 1
jbals Accepted Answer Pending Moderation
0
Votes
Undo

Yes, they are...

I made some tests. It seems to me, that the home directory ($ARP_ACTIVE_APPS_DIR/app_id) is not existing, when the init.d script is invoked.

  1. more than a month ago
  2. PLCnext Store
  3. # 2
Martin PLCnext Team Accepted Answer Pending Moderation
0
Votes
Undo

Hmm, I will need to check with the developer, if the app directory does not exist when the init.d script for that app is first invoked during app installation.

But even if that is the case - after the app is installed, the app directory will certainly exist when the init.d script is run during the next device restart. So, your daemon should successfully start after a device reboot.

Is this what you see?

Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support

  1. more than a month ago
  2. PLCnext Store
  3. # 3
jbals Accepted Answer Pending Moderation
0
Votes
Undo

I think I finally found the origin of the problem. After a reboot the situation got even worse. Now both directories (defined by ARP_APPS_HOME_DIR and ARP_APPS_DATA_DIR) seemed to be missing. I checked it and the directories were existing. What is really missing are the environment variables. During the init.d call on system startup they are not set. I fixed it by using the template mechanism for the init.d script with the @@@VAR_NAME@@@ parameters, because it is a general problem to rely on environment variables during startup. But I think this is still a problem, because one of the environment variables was not set when I started the app after installation via the WBM. I would expect that environment variables are definitely set during runtime after the installation.

  1. more than a month ago
  2. PLCnext Store
  3. # 4
Daniel PLCnext Store Team Accepted Answer Pending Moderation
0
Votes
Undo

> ... because one of the environment variables was not set when I started the app

Which environment variable you did not find?

 

This is the template file:

Here you have the opertunity to export enviroment variables to your process:

# Starting Daemon
dm_start()
{
start-stop-daemon --start --quiet --exec /usr/bin/env APPTEMPDIRECTORY="@@@APPTEMPDIRECTORY@@@" APPDATADIRECTORY="@@@APPDATADIRECTORY@@@" $DAEMON -- $DAEMON_ARGS &
}

 

 

Phoenix Contact Electronics Headquarters - PLCnext Store Team

  1. more than a month ago
  2. PLCnext Store
  3. # 5
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.