Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
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. -
-
donuts236785y@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.... -
@billgates No idea, but I would guess yes? Just check if the pid in the file is the pid of the server.
-
donuts236785y@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? -
@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 -
donuts236785y@sbiewald hmm guess will need to look into it a bit more then or how to convert the pm2 startup call to systemd.
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
question