You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PID=$({{foreverPath}}forever --plain list | sed -n -e '/data:\s*\[[0-9]*\]\s\({{service}}\)\s/p'| awk '{print $7}')
I have created the service with the install command: sudo forever-service install randomService --script /opt/randomService/bin/www --scriptOptions " --option1=\"One\" --option2=2 --option3=3" --start
The service is created, enabled and is running.
I then went ahead and tried to stop the service using: sudo service randomService stop
Which returns successfully.
Testing with sudo forever list however, shows that the process was not stopped.
Investigating this i found that the service script '/etc/init.d/randomService' are using the 'forever list' piped through sed and awk to find the PID. But awk is always looking at index seven: awk '{print $7}'
Running this command-set in cli returned '--option2=2' instead of the PID...
Instead of counting from the beginning and handle the variable command width it could be fixed by counting from the end instead using awk '{print $(NF-2)}'.
I do not think that this would break anything, but please prove me wrong.
Piping through awk as in the current template: sudo /usr/bin/forever --plain list | sed -n -e '/data:\s*\[[0-9]*\]\s\(randomService\)\s/p' | awk '{print $7}'
Result: --option2=2
Piping through awk counting from the back: sudo /usr/bin/forever --plain list | sed -n -e '/data:\s*\[[0-9]*\]\s\(randomService\)\s/p' | awk '{print $(NF-2)}
Result: 555
Regards
Thomas
The text was updated successfully, but these errors were encountered:
forever-service/templates/sysvinit/initd.template
Line 161 in 54a2ad4
I have created the service with the install command:
sudo forever-service install randomService --script /opt/randomService/bin/www --scriptOptions " --option1=\"One\" --option2=2 --option3=3" --start
The service is created, enabled and is running.
I then went ahead and tried to stop the service using:
sudo service randomService stop
Which returns successfully.
Testing with
sudo forever list
however, shows that the process was not stopped.Investigating this i found that the service script '/etc/init.d/randomService' are using the 'forever list' piped through sed and awk to find the PID. But awk is always looking at index seven: awk '{print $7}'
Running this command-set in cli returned '--option2=2' instead of the PID...
Instead of counting from the beginning and handle the variable command width it could be fixed by counting from the end instead using awk '{print $(NF-2)}'.
I do not think that this would break anything, but please prove me wrong.
Example
Cmd:
sudo /usr/bin/forever --plain list | sed -n -e '/data:\s*\[[0-9]*\]\s\(randomService\)\s/p'
Result:
data: [0] randomService /usr/bin/node /opt/randomService/bin/www --option1=\"One\" --option2=2 --option3=3 543 555 /var/log/randomService.log 0:2:27:7.595
Piping through awk as in the current template:
sudo /usr/bin/forever --plain list | sed -n -e '/data:\s*\[[0-9]*\]\s\(randomService\)\s/p' | awk '{print $7}'
Result:
--option2=2
Piping through awk counting from the back:
sudo /usr/bin/forever --plain list | sed -n -e '/data:\s*\[[0-9]*\]\s\(randomService\)\s/p' | awk '{print $(NF-2)}
Result:
555
Regards
Thomas
The text was updated successfully, but these errors were encountered: