I want to use PM2 to manage all of my processes, even non node ones. I have some processes written in Haskell and Go (which are compiled) and run in a bash environment. Does PM2 accommodate this use case?
Yes, you can use PM2 in fork mode with exec interpreter set to none.
@ravi With exec_interpreter set to bash, the restart and stop commands fail, is this to be expected?
Are you running a bash script? Try setting it to none, I think.
Yep. That works.
Is there an example of this somewhere?
Yeah, wondering if there's any documentation that could be added for non-node executables.
Sure http://pm2.keymetrics.io/docs/usage/process-management/#start-any-process-type
and how would I pass this binary a file it needs?
For instance I would start my postgrest (https://github.com/begriffs/postgrest) server like this:
./postgrest postgrest.conf
postgrest.conf is a configuration file that postgrest needs.
When I do
pm2 start ./postgrest postgrest.conf
the process errors out.
So how should I pass this file to postgrest?
@barbalex you should use pm2 start ./postgrest -- postgrest.conf, -- is needed to tell PM2 that you want to define arguments for the process and not for PM2 itself
@vmarchaud Thanks a lot. For your answer and most of all for helping build this great tool.
Somehow I missed that important detail in the documentation. It probably is there but as someone not much into this matter I guess I just did not know how to search correctly.
Maybe this is a general way to do this sort of thing in node and that is why it is not mentioned in the pm2 docs? If so I would plead to add this example for all the poor frontend folks like me ;-)
@barbalex It's documented there (second line), but it's common for unix tools to use -- as a indicator to stop parsing arguments.
For example, if you want to ls on a file called -a, you can't run ls -a because thats an option, you need to use ls -- -a :)
@vmarchaud thanks a lot for clarifying that. So it's true that this is a catch for noobs like me who think this may be a node thing when it really is unix ;-)
Any way I offered clarifying this in the postgrest repository (https://github.com/begriffs/postgrest-docs/issues/105) where it would have been most helpful for me.
@barbalex If you want our docs is hosted here, feel free to make a PR if you want to
Most helpful comment
Is there an example of this somewhere?