Linux init script

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Linux init script

Sebastián Filippini
Hello everyone,

I'm trying to write a Linux init script for a Pharo application. I'm
using a bash script wrapper to launch pharo. This script executes the
pharo script provided by get.pharo.org.

This is my wrapper script:

#! /bin/bash

cd "$(dirname "$0")"
./pharo myapp.image start.st &
PID=$!
echo $PID > /var/run/myapp.pid

The following process tree is created:

   ├─bash,692 ./pharo myapp.image start.st
   │   └─pharo,701 --nodisplay myapp.image start.st
   │       └─{pharo},730

And a /var/run/myapp.pid file is written with 692. Ok.

The problem is that when I kill the process with pid 692 the process
with pid 701 is not terminated.

Any idea on how I can terminate the whole process tree?

Best regards,
Sebastián Filippini

Reply | Threaded
Open this post in threaded view
|

Re: Linux init script

K K Subbu
On 10/07/19 10:30 PM, Sebastián Filippini wrote:
> Hello everyone,
>
> I'm trying to write a Linux init script for a Pharo application. I'm
> using a bash script wrapper to launch pharo. This script executes the
> pharo script provided by get.pharo.org.
>
> ./pharo myapp.image start.st &
> PID=$!
> echo $PID > /var/run/myapp.pid

You could try direct exec instead of spawning a subshell. E.g.

echo $$ >/var/run/myapp.id
exec ./pharo myapp.image start.st

HTH .. Subbu