1
donuts
4y

I'm migrating a node app from rh6 to 7, initd to systemd...

Init.d runs start.sh which then spawns calls pm2 with the args. The problem though seems to be (I set the service to be forking otherwise it doesn't let it or kills the child threads?) But then there service then says it fails since I guess the script exited by itself...

And therefore the stop didn't work either?

I just need a service that acts as a link? To the actual start stop scripts and just run them? Without killing the could orocesses

Comments
  • 4
    AFAIK for forking you should give systemd the location of the pidfile.

    An extreme option would be "oneshot" where you would give systemd a start and stop command - on the other hand, it will not know anymore if the service is actually running or not...

    However the "best" option would probably be: Systemd replaces the start/stop scripts totally (or if the start process requires a complicated setup, run a script which "exec"s to the real application and the real application must not daemonize anymore) and stop it by a signal.
  • 0
    Blerg

    I feel ya

    https://freedesktop.org/software/...

    Type forking

    Beware of temp protection
  • 0
    @sbiewald Can I just give the file under .pm2/pids? Not sure how that works as the file itself seems empty so not sure what it's used for..

    I did try oneshot and it starts ok. But seems it don't recognize ExecStop... Maybe should try forking again with pid... Next week.

    Ahh so this simple problem I assume was solved and gave to a jr actually turns out to be not that simple....
  • 1
    @billgates No idea, but I would guess yes? Just check if the pid in the file is the pid of the server.
  • 0
    @sbiewald but I mean the file is just like a lock? If it exists then it means the app is running, otherwise no?

    Sorta worried though like it the app crashes... Then if I run start, it'll just say it's already running?
  • 0
    @billgates If your app runs, the pid file contains the process id ("pid") of your app's process.
    If your app does not run, it may be empty nonexistent or contain the pid of your app before it stopped.

    Systemd the can now do:
    - Check if your app still runs (does a process for the pid in the file still exist and is the executable the same; otherwise your app does not run)
    - Send the SIGTERM signal to the correct process to shut it down
  • 0
    @sbiewald hmm guess will need to look into it a bit more then or how to convert the pm2 startup call to systemd.
Add Comment