Skip to main content
Topic: Non-systemd init script for Neo4j application (Read 200 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Non-systemd init script for Neo4j application

The neo4j package installs a systemd init script, which Artix does not use systemd, so I'm trying to write an OpenRC init script for neo4j and need help figuring out why it's not working.

Here is what I have so far:
Code: [Select]
name="$RC_SVCNAME"
description="Neo4j: Graphs for Everyone."
cfgfile="/etc/$RC_SVCNAME/$RC_SVCNAME.conf"
command="/usr/bin/neo4j"
command_background="yes"
command_user="neo4j:neo4j"
pidfile="/run/$RC_SVCNAME/$RC_SVCNAME.pid"

start_pre() {
  if [ ! -f /etc/neo4j/neo4j.conf ] ; then
    eerror "Please create /etc/neo4j/neo4j.conf"
    return 1
  fi
  return 0

When I run "sudo rc-service neo4j status", I get
 * status: stopped

When I run "sudo rc-service neo4j start", I get
 * Starting neo4j ... * start-stop-daemon: fopen `/run/neo4j/neo4j.pid': No such file or directory
 [ ok ]

Then I run "sudo rc-service neo4j status" again and this time I get
 * status: crashed

So I manually create a /run/neo4j directory and then run "sudo rc-service neo4j start", and get
 * WARNING: neo4j has already been started

but when I run "sudo rc-service neo4j status", I get that it's crashed again.

Then I run "sudo rc-service neo4j stop" and I get
 * Stopping neo4j ... * start-stop-daemon: no matching processes found
 [ ok ]

Ideas on how to fix the script to work? This could become the neo4j-openrc Artix package.

Re: Non-systemd init script for Neo4j application

Reply #1
I used this perl script to convert the neo4j systemd init script to an OpenRC version, and it appears to be working when I run
Code: [Select]
$ sudo rc-service neo4j start
[sudo] password for USERNAME:
 * Caching service dependencies ... [ ok ]
 * Starting neo4j ...Directories in use:
home:         /var/lib/neo4j
config:       /etc/neo4j
logs:         /var/lib/neo4j/logs
plugins:      /var/lib/neo4j/plugins
import:       /var/lib/neo4j/import
data:         /var/lib/neo4j/data
certificates: /var/lib/neo4j/certificates
licenses:     /var/lib/neo4j/licenses
run:          /var/lib/neo4j/run
Starting Neo4j.
2024-10-03 01:34:51.527+0000 INFO  Logging config in use: Embedded default config 'default-user-logs.xml'
2024-10-03 01:34:51.548+0000 INFO  Starting...
2024-10-03 01:34:52.282+0000 INFO  This instance is ServerId{65e54120} (65e54120-0341-40f9-8b73-1cb1104a1843)
2024-10-03 01:34:53.266+0000 INFO  ======== Neo4j 5.24.0 ========
2024-10-03 01:34:55.300+0000 INFO  Anonymous Usage Data is being sent to Neo4j, see https://neo4j.com/docs/usage-data/
2024-10-03 01:34:55.329+0000 INFO  Bolt enabled on localhost:7687.
2024-10-03 01:34:55.769+0000 INFO  HTTP enabled on localhost:7474.
2024-10-03 01:34:55.769+0000 INFO  Remote interface available at http://localhost:7474/
2024-10-03 01:34:55.772+0000 INFO  id: C0A3C6D86D12C57FD02A9D581050097A3B638BCDD14FF15249878B50674CB519
2024-10-03 01:34:55.772+0000 INFO  name: system
2024-10-03 01:34:55.772+0000 INFO  creationDate: 2024-10-03T01:34:54.182Z
2024-10-03 01:34:55.772+0000 INFO  Started.

It just shows it running at CLI and doesn't return back to the prompt as is expected from OpenRC init scripts. Then when I try to "sudo rc-service neo4j stop" it, it does not stop, so I try ctrl+C and that bring me back to interactive CLI:
Code: [Select]
^C * neo4j: caught SIGINT, aborting
 * start-stop-daemon: caught SIGINT, aborting

Then I try to start neo4j back up with "sudo rc-service neo4j start" and I get
Code: [Select]
 * Starting neo4j ...Neo4j is already running (pid:23821).
Run with '--verbose' for a more detailed error message.
 * start-stop-daemon: failed to start `/usr/bin/neo4j'
 * Failed to start neo4j
                                                            [ !! ]
 * ERROR: neo4j failed to start

When I run "sudo rc-service neo4j status", it shows
 * status: stopped

It is still running with a check from "ps aux | grep neo4j"

This init script the perl script above created is:
Code: [Select]
#!/sbin/openrc-run

command=/usr/bin/neo4j
command_args="console"
pidfile=

name="neo4j"
description="Neo4j Graph Database"

Any help getting this OpenRC init script working?