Re: Script doesn't stop opensearch

2024-01-04 Thread Omar Polo
On 2024/01/04 19:44:01 +, Mik J  wrote:
> [...]
> I still have a question Omar, you wrote that the pexp content would be matched
> "the daemon is found by looking for a process matching that pexp and killing 
> it."
> 
> Here I have
> pexp="$(/usr/local/bin/javaPathHelper -c opensearch) 
> .*org.opensearch.bootstrap.OpenSearch.*"

the $(...) part is evaluated and its output then substituted, so the
pexp effectively is

/usr/local/jdk-11/bin/java .*org.opensearch.bootstrap.Opensearch.*

You can double-check by just copy-pasting pexp="$(...) ..." in a shell
and then dumping the value of pexp, for e.g.: echo $pexp

Just like you've found, you may get a slightly different java path
depending on what you've set JAVA_HOME to.

(maybe javaPathHelper could strip extra / at the end; it would have
prevented this issue.)


Cheers,

Omar Polo



Re: Script doesn't stop opensearch

2024-01-04 Thread Mik J
Hello Mike, Omar, Stuart,

Thank you for your answers, I've learnt a lot through these.

It seems that my problem was due to the fact that I added this variable in my 
/root/.profile
export JAVA_HOME=/usr/local/jdk-11/

# cat /var/run/rc.d/opensearch
was then showing a double slash
pexp=/usr/local/jdk-11//bin/java .*org.opensearch.bootstrap.OpenSearch.*

By removing the ending slash in the root .profile, the double slash disapeared 
and I have been able to use /etc/rc.d/opensearch stop since then. And also with 
the check parameter which didn't work at the time.

I still have a question Omar, you wrote that the pexp content would be matched
"the daemon is found by looking for a process matching that pexp and killing 
it."

Here I have
pexp="$(/usr/local/bin/javaPathHelper -c opensearch) 
.*org.opensearch.bootstrap.OpenSearch.*"

But in the ps command javaPathHelper doesn't appear so it can't match it
# COLUMNS=1600  ps ax -o command | grep Dopensearch
/usr/local/jdk-11/bin/java -Xshare:auto 
-Dopensearch.networkaddress.cache.ttl=60 
-Dopensearch.networkaddress.cache.negative.ttl=10 -XX:+AlwaysPreTouch -Xss1m 
-Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true 
-XX:-OmitStackTraceInFastThrow -Dio.netty.noUnsafe=true 
-Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 
-Dio.netty.allocator.numDirectArenas=0 -Dlog4j.shutdownHookEnabled=false 
-Dlog4j2.disable.jmx=true -Djava.locale.providers=SPI,COMPAT -Xms6g -Xmx6g 
-XX:+UseG1GC -XX:G1ReservePercent=25 -XX:InitiatingHeapOccupancyPercent=30 
-Djava.io.tmpdir=/tmp/opensearch-18321662122565322049 
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=data 
-XX:ErrorFile=/var/log/opensearch/hs_err_pid%p.log 
-Xlog:gc*,gc+age=trace,safepoint:file=/var/log/opensearch/gc.log:utctime,pid,tags:filecount=32,filesize=64m
 
-Djava.util.concurrent.ForkJoinPool.common.threadFactory=org.opensearch.secure_sm.SecuredForkJoinWorkerThreadFactory
 -XX:MaxDirectMemorySize=3221225472 
-Dopensearch.path.home=/usr/local/opensearch 
-Dopensearch.path.conf=/etc/opensearch -Dopensearch.distribution.type=tar 
-Dopensearch.bundled_jdk=true -cp 
/usr/local/opensearch/lib/*:/usr/local/share/java//classes//jna.jar:/usr/local/share/java//classes//jna-platform.jar
 org.opensearch.bootstrap.OpenSearch -d -p /var/run/opensearch/opensearch.pid

Thank you




Le jeudi 4 janvier 2024 à 14:36:05 UTC+1, Stuart Henderson 
 a écrit : 





On 2024-01-03, Mik J  wrote:
> Hello,
>
> I don't understand how the startup/stop script works

It uses the string from pexp (as it was when the daemon was _started_;
changes to the rc script after startup are ignored) with pgrep(1) -xf to
identify the running process (and pkill -xf to actually signal it).

> I can confirm that the pid I see in /var/run/opensearch/opensearch.pid is the 
> same I see in ps ax | grep opensearch
>
> However when I want to stop the process
> # /etc/rc.d/opensearch stop
> Nothing happens

Show the contents of /var/run/rc.d/opensearch and the output of some
pgrep command that identifies the process (e.g. pgrep -lf opensearch).

> And I don't understand how this stop command would do something like that
> # kill -15 `cat /var/run/opensearch/opensearch.pid`

rc.d doesn't use pid files. If the daemon exited without cleaning the
file (e.g in a crash) the pid may have been re-used by another process.

-- 
Please keep replies on the mailing list.



Re: Script doesn't stop opensearch

2024-01-04 Thread Stuart Henderson
On 2024-01-03, Mik J  wrote:
> Hello,
>
> I don't understand how the startup/stop script works

It uses the string from pexp (as it was when the daemon was _started_;
changes to the rc script after startup are ignored) with pgrep(1) -xf to
identify the running process (and pkill -xf to actually signal it).

> I can confirm that the pid I see in /var/run/opensearch/opensearch.pid is the 
> same I see in ps ax | grep opensearch
>
> However when I want to stop the process
> # /etc/rc.d/opensearch stop
> Nothing happens

Show the contents of /var/run/rc.d/opensearch and the output of some
pgrep command that identifies the process (e.g. pgrep -lf opensearch).

> And I don't understand how this stop command would do something like that
> # kill -15 `cat /var/run/opensearch/opensearch.pid`

rc.d doesn't use pid files. If the daemon exited without cleaning the
file (e.g in a crash) the pid may have been re-used by another process.

-- 
Please keep replies on the mailing list.



Re: Script doesn't stop opensearch

2024-01-04 Thread Stuart Henderson
On 2024-01-04, Mike Fischer  wrote:
>
>> Am 04.01.2024 um 00:06 schrieb Mik J :
>> 
>> However when I want to stop the process
>> # /etc/rc.d/opensearch stop
>> Nothing happens
>
> try:
> # rcctl stop opensearch
>
> You are not supposed to ever call the /etc/rc.d/* scripts directly.

no, that's fine too.

-- 
Please keep replies on the mailing list.



Re: Script doesn't stop opensearch

2024-01-04 Thread Omar Polo
On 2024/01/03 23:06:57 +, Mik J  wrote:
> Hello,
> 
> I don't understand how the startup/stop script works
> 
> # cat /etc/rc.d/opensearch
> #!/bin/ksh
> 
> daemon="/usr/local/opensearch/bin/opensearch"
> daemon_flags="-d -p /var/run/opensearch/opensearch.pid"
> daemon_user="_opensearch"
> 
> . /etc/rc.d/rc.subr
> 
> pexp="$(/usr/local/bin/javaPathHelper -c opensearch) 
> .*org.opensearch.bootstrap.OpenSearch.*"

  

this is the "magic" that powers rcctl check and stop.  The pidfile is
not used by the rc infrastructure (at least for opensearch), the daemon
is found by looking for a process matching that pexp and killing it.

You can check /etc/rc.d/rc.subr to see what exactly happens.

> rc_reload=NO
> 
> rc_pre() {
>     install -d -o _opensearch /var/run/opensearch/
> }
> 
> rc_cmd $1
> 
> 
> I can confirm that the pid I see in /var/run/opensearch/opensearch.pid is the 
> same I see in ps ax | grep opensearch
> 
> However when I want to stop the process
> # /etc/rc.d/opensearch stop
> Nothing happens

What do you mean with 'Nothing happens'?  Here it prints
'opensearch(ok)' and then the daemon is stopped.  (I generally use
rcctl, but the output and behaviour is the same.)



Re: Script doesn't stop opensearch

2024-01-03 Thread Mike Fischer


> Am 04.01.2024 um 00:06 schrieb Mik J :
> 
> However when I want to stop the process
> # /etc/rc.d/opensearch stop
> Nothing happens

try:
# rcctl stop opensearch

You are not supposed to ever call the /etc/rc.d/* scripts directly.


HTH
Mike



Script doesn't stop opensearch

2024-01-03 Thread Mik J
Hello,

I don't understand how the startup/stop script works

# cat /etc/rc.d/opensearch
#!/bin/ksh

daemon="/usr/local/opensearch/bin/opensearch"
daemon_flags="-d -p /var/run/opensearch/opensearch.pid"
daemon_user="_opensearch"

. /etc/rc.d/rc.subr

pexp="$(/usr/local/bin/javaPathHelper -c opensearch) 
.*org.opensearch.bootstrap.OpenSearch.*"

rc_reload=NO

rc_pre() {
    install -d -o _opensearch /var/run/opensearch/
}

rc_cmd $1


I can confirm that the pid I see in /var/run/opensearch/opensearch.pid is the 
same I see in ps ax | grep opensearch

However when I want to stop the process
# /etc/rc.d/opensearch stop
Nothing happens

And I don't understand how this stop command would do something like that
# kill -15 `cat /var/run/opensearch/opensearch.pid`

Thank you