AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   HL1 Servers (HLDS) (https://forums.alliedmods.net/forumdisplay.php?f=131)
-   -   Starting hlds with PID (https://forums.alliedmods.net/showthread.php?t=269847)

gloBi 08-11-2015 05:59

Starting hlds with PID
 
Hello, everybody!

I want to know how to start my server with predefined PID? I tried with -pidfile pid.pid, where in pid.pid there is the predefined PID, but it doesn't work.

pid.pid file is located in the same directory as hlds and the starting script.

Any suggestions how to make it?

Thanks in advance.

aron9forever 08-11-2015 08:45

Re: Starting hlds with PID
 
please explain why you need this
it's a very bad practice to do this, pids are supposed to be random

just tell what you need it for, I'm pretty sure it can be made in another way

gloBi 08-11-2015 09:56

Re: Starting hlds with PID
 
I want to use Monit to monitor my servers. So if one server has crashed with 100% cpu usage, monit will restart it, but Monit works with PID. :)

MetalMessiah 08-11-2015 10:55

Re: Starting hlds with PID
 
I think PID is a system process identificator, you can't submit your own.
Everything you can do is to start a process andget it's PID for monitoring.

P.S. I've never seen server crashed due to 100% CPU. You'll get FPS around 4.00 but not crash :)

gloBi 08-12-2015 07:44

Re: Starting hlds with PID
 
So you have never seen anything :)

Some buggy plugin crashes the server and it starts using 100% cpu.

So, I still think there is a way to set pid, should be, so anyone help?

fysiks 08-12-2015 09:25

Re: Starting hlds with PID
 
The only thing that you can do is start the server and get the PID that was given to it by the operating system. There's no reason to want to do it any other way.

Kia 08-12-2015 11:51

Re: Starting hlds with PID
 
I use Monit too and everything is working fine using -pidfile

gloBi 08-13-2015 07:51

Re: Starting hlds with PID
 
Quote:

Originally Posted by Kia (Post 2332374)
I use Monit too and everything is working fine using -pidfile

So, where is my mistake? I'm starting the server like that:

./hlds_run -game cstrike +ip -port -pidfile pid.pid +rcon_password ....

and file pid.pid is located where starting script is located. I tried also to give full path, but same.

@fysiks
If there is a way monit to get the PID of started server, OK, tell me how to make it.



EDIT: Aha, I tried with --pidfile /full/path and it works :)

EDIT 2: Now I understand, it is not predefined PID, --pidfile option just writes the pid of the started server in a file, so everytime when i start the server, the PID is different. And Monit read that pid file and knows which process is the server :)

Now i should think about start/stop/restart script, any ideas here ? :)

aron9forever 08-13-2015 13:28

Re: Starting hlds with PID
 
Quote:

Originally Posted by gloBi (Post 2332650)
So, where is my mistake? I'm starting the server like that:

./hlds_run -game cstrike +ip -port -pidfile pid.pid +rcon_password ....

and file pid.pid is located where starting script is located. I tried also to give full path, but same.

@fysiks
If there is a way monit to get the PID of started server, OK, tell me how to make it.



EDIT: Aha, I tried with --pidfile /full/path and it works :)

EDIT 2: Now I understand, it is not predefined PID, --pidfile option just writes the pid of the started server in a file, so everytime when i start the server, the PID is different. And Monit read that pid file and knows which process is the server :)

Now i should think about start/stop/restart script, any ideas here ? :)

if you know full path to binary, there's "pidof" to use
example
PHP Code:

pidof /home/user3/server100/cs/hlds_i686 

will return process PID if it's launched so no needs for pid files

gloBi 08-13-2015 18:12

Re: Starting hlds with PID
 
@aron9forever, yeah, but do you know how Monit works :)


All times are GMT -4. The time now is 14:36.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.