Resque with God uses IO.popen - gnu

I am under rvm.
I have god.
It starts resque.
Resque job opens an IO.popen to the local system program, sends it some text, gets some text back from the stream, analyses it a bit, closes the IO.
So: when I run resque as rake resque:work — it's ok, everything works.
When I start resque from god run from user, it works.
Now I have made god working from init.d, made rvm wrapper, start it as sudo... So now the communication with IO is somehow broken. Resque failed web-report says
Unexpected response format
/home/dakemen/.rvm/gems/ruby-2.0.0-p0/bundler/gems/go_gtp-5cd5a4de65cb/lib/go/gtp.rb:451:in `send_command'
I have some other resque jobs, that do not do anything with IO. They work.
The gem I use to open IO to the local application is
https://github.com/JEG2/go_gtp/blob/master/lib/go/gtp.rb
=========
Experiment:
So, all resque workers are started as sudo. Ok. And the worker refers to gnugo.
user$ gnugo
GNU Go 3.8 and so on works great
user$ sudo gnugo
sudo: gnugo: command not found (WHY?)
user$ sudo echo $PATH
.......... /usr/games:/usr/local/games

Ok.
I just don't rely on the PATH, opening an IO, but give full path to the service being run as IO stream.

Related

Make chosen version of Elasticsearch run as a service in Linux

I have an issue with later versions of ES, so have to use 7.10.2 currently.
This means that the previous method I used to install ES as a service, i.e. apt-get, doesn't work You can't choose an older version this way: it currently installs 7.16.3.
So I followed the procedure on this page for 7.10: everything worked: I was able to run ES as an app and also as a "daemon". Clearly I could simply put the "daemon" startup line in a script which runs on boot.
But what's the optimum way of turning this "daemon arrangement" into a service which you can control with systemctl, and which starts automatically when the machine boots?
PS I don't want to get involved with Docker. I'm sure that's a useful thing but I'm convinced there is a simpler way of doing it, using available Linux sys tools.
I found a workaround... this doesn't in fact create a service of the "systemd" type which can be controlled by systemctl. There seem to be one or two problems which make this non-trivial.
1) You can't start ES as root! I assume (not sure) that most services are being run by root. Anyway this was something I couldn't find a solution to.
2) I am not sure whether a shell script file called by a service is allowed to end... or should continue endlessly: initially I thought this would be sufficient. This is a shell script (run_es_daemon.sh) which does indeed start up ES (as a daemon process) when run by manually in a terminal. There is no issue to do with the fact that the script ends and you then close the terminal: the daemon process continues to run:
#!/bin/bash
# start ES as a daemon...
cd /home/mike/Elasticsearch/elasticsearch-7.10.2
./bin/elasticsearch -d -p pid
... but it never worked using a xxx.service file in /etc/systemd/system/ (maybe because of 1) above). So I also tried adding these lines under the above ones:
while true
do
echo "bubbles"
sleep 60
done
... didn't work either.
In the end I found a simple workaround solution was to start up the daemon process by using crontab:
#reboot /home/mike/sysadmin/run_es_daemon.sh
... but I'd still like to know how to set it up as a true service, which starts at boot...

Running gvfs after building

I am trying to run a local build of gvfs. I have followed the Newcomers document to set up a working build environment, built gvfs from sources and am now trying to figure out how to run it.
The docs have instructions on running applications or the GNOME shell, which say I need to kill the current instance, then launch the newly-built binary with jhbuild run, as in:
$ killall gnome-weather
$ jhbuild run gnome-weather
or, in the case of the shell,
$ jhbuild run gnome-shell --replace
For gvfs, I see that it spawns a bunch of processes (all children of P1 running under my account), the first of them (lowest PID) being gvfsd. So I tried the following:
$ killall gvfsd
$ jhbuild run gvfs
Which gives me the error message:
jhbuild run: Unable to execute the command 'gvfs': [Errno 2] No such file or directory
If instead I try
$ jhbuild run gvfsd
I get the same message. Same when I try any of the above two with --replace.
Since gvfs is a daemon rather than an application, I searched around a bit and came across this post, which suggests launching daemons with
jhbuild run dbus-launch --exit-with-session name-of-daemon
No joy either... no matter whether I use gvfs or gvfsd for the name, I get the error message
Couldn't exec gvfs: No such file or directory
(reporting the name I specified in the command).
Is this the correct way to launch gvfs at all? If not, what is? If it is, how can I find out what's going wrong?
EDIT: Apparently, the code I intend to modify is part of the gvfs-mtp-volume-monitor binary – but essentially the same goes here. How do I launch my own version of the binary rather than the one that came with my OS distro?
jhbuild run can be used for gvfs in the same manner.
For gvfsd do the following:
jhbuild run ~/jhbuild/install/libexec/gvfsd -r
The -r switch tells gvfsd to replace any running version. gvfsd will also start gvfsd-fuse if it was built and you didn't disable it via a command-line switch.
You will also need to replace any volume monitors (and other processes you need), such as:
killall gvfs-mtp-volume-monitor
jhbuild run ~/jhbuild/install/libexec/gvfs-mtp-volume-monitor
Care must be taken with anything that is invoked over dbus:
Namespaces may change between versions. If that happened between the version shipped with your OS and the current one, the latter will not work unless you tweak your dbus config to reflect that.
If dbus is used to spawn processes, it will fall back to the binaries shipped with your OS. Again you would need to modify your dbus config (specifically .service entries) to point to your binaries.

PM2 resurrect not working on reboot - dump.pm2 being emptied

I'm trying to configure PM2 to daemonize a simple node.js server on centos. The init.d script executes, and there are no errors, but pm2 list returns an empty list, and the server is not starting.
Originally, I was attempting to start the process as a different user (for those interested, this can be done with modifications to pm2-init.sh). But due to the complication, I decided to first try to get it to run as root.
The strange symptom of the problem is that the dump.pm2 file is being emptied by some process, thus the pm2 resurrect has nothing to do. I set up pm2 to run on reboot as follows
$ pm2 startup centos
$ pm2 start /path/to/my/server.js
$ pm2 save
At this point, dump.pm2 had a large JSON object in it and the server is running. Then, running:
$ reboot
... wait and log back in
$ pm2 list
It was empty again, and so was the dump.pm2!
I'm not sure what process is clearing this file. I've tried reinstalling and re-running the startup script to no avail. Any help is greatly appreciated.
As a temporary workaround, I set the dump file as immutable:
$ chattr +i /path/to/my/dump.pm2
This worked. Although not ideal, it is what I will use until I can determine why the dump.pm2 file is being emptied.

gearman stop start restart command

What are the command to start, restart and stop gearman?
So far I know:
gearadmin --shutdown # stop
gearmand -d # I believe it is to restart. Not sure.
Any idea for managing gearman?
If you want to restart the gearmand, then you should use the shell script gearman-job-server. Type the command as sudo service gearman-job-server restart which STOPs and STARTs the server
---------------------- More Information If you need it -----------------------
I assume you have some small confusion over here. It's all because of Terminologies. The name of the application is Gearman which is a Message-Queue System.
I am answering with the assumption tha you are working with Linux OS.
When you try installing the Gearman, the application that gets installed is gearmand which is a Job-Server/executable file. Something like Apache for example.
Refer the link http://manpages.ubuntu.com/manpages/precise/en/man8/gearmand.8.html for the command reference.
Then what's the gearman? gearman is the Client Program/Application, with which you can talk to the gearmand. With gearman you can run client and worker functions from the command line.
Refer the link http://manpages.ubuntu.com/manpages/precise/en/man1/gearman.1.html for the command reference.
So what's gearadmin? It's the tool which allows you to run Admin commands against your gearmand
Refer the link: http://manpages.ubuntu.com/manpages/precise/en/man1/gearadmin.1.html
Now coming to your questions about the command gearmand. From the shell if you run the command as gearmand, the Job Server starts and gets attached to your Shell Process. For ex: if you run php from shell the php runs and starts waiting for your commands right? Same way. If you want to run Gearmand as a background process, then you should run with the param as -d which makes it run as a daemon
So gearmand -d makes it run as Daemon. Not a restart command.
Hope this helps to answer your question and also to clarify in case if you have any confusion over the naming.
How to STOP Gearman Server
==> gearadmin --shutdown
How to START Gearman Server
==> gearmand -d
The popular answer seems to be a bit old, so if you get Failed to restart gearman-job-server.service: Unit not found. when trying to restart the old way, try just sudo service gearmand restart. That's how it seems to work on a CentOS with latest version of gearman.
For restarting the workers on the same system there seems to be a sudo gearmanw-control restart command avaliable.

Installing ElasticSearch on Linux

I'm trying to install ElasticSearch on a Linux environment. I'm almost there, but I'm doing something wrong.
Basically, my issue is this: when I run bin/elasticsearch in the terminal, I can access http://localhost.com:9200 just fine and run queries. But when I end the SSH session, I get a 404 when I try to hit http://localhost.com:9200 both in my browser window and through CURL.
This is the process I used to install ElasticSearch:
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.1.0.tar.gz
tar -zxvf elasticsearch-1.1.0.tar.gz
cd elasticsearch-1.1.0
bin/elasticsearch
Like I said, this works, and I can hit http://localhost.com:9200 to run queries, but only as long as the SSH session is active.
Is there something obvious I'm doing wrong? I'm a novice at command line stuff, so I'm trying to feel my way through.
From 1.0 onwards the default option launches the service in foreground
ElasticSearch Documentation http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/_system_and_settings.html
Try using the "-d" option which runs the server as a daemon.

Resources