Supervisord: How to use the hostname in a startup command - supervisord

is it possible to somehow use the local hostname in a supervisord startup script?
I need it to pass the jmx host to a java-Program.
Example:
command=HOSTNAME=foo.bar /usr/local/rvm/bin/jruby-1.7.1 script/trinidad.rb --threadsafe -f config/trinidad_user_production.rb
I see no easy option so far.
Best,
Tobias

For using hostname in the config file:
%(host_node_name)s

environment=HOSTNAME=foo.bar should work without any issues.
See: http://supervisord.org/subprocess.html#subprocess-environment

Related

Validate haproxy.cfg

Is there any way to validate the HAProxy haproxy.cfg file before restarting the HAProxy service? For example: There might be a small spelling/syntax error in a larger haproxy.cfg file. I searched through several forums, but was unable to find anything in relation to validating the haproxy.cfg files for syntax errors.
As of now, I use a trial and error basis on a developer machine before I upload the changes to a Production Server.
The official HaProxy configuration file check was buried in the help sections.
/usr/local/sbin/haproxy --help
There are two ways to check the haproxy.cfg syntax is to use..
One way is the /usr/local/sbin/haproxy -c -V -f /etc/haproxy/haproxy.cfg
which validates the file syntax. The -c switch in the command represents the Check, while the others denote "Verbose" & "file".
Another way is to sudo service haproxy configtest
I hope this helps anyone looking to check the syntax of the haproxy.cfg file before restarting the service.
We are using this command
sudo haproxy -f /etc/haproxy/haproxy.cfg -c

Gitlab, docker and sendmail ports

I have got gitlab running through docker using this image. In the image documentation there are instructions for how to configure an optional SMTP server for emails, but little information on what happens if SMTP is not set up. The gitlab documentation indicates that sendmail is used by default, so I assume that is what happens, and for my purposes (a few private repositories with only a couple of users) I don't think I really need any more than sendmail. I tried just ignoring the SMTP configuration and it all runs fine, but emails are not sent. I don't know enough about email servers or sendmail to know how to find the problem, but my guess is that some port it needs is blocked.
My questions:
Can anyone confirm than sendmail is used, and that I don't need to configure something?
Is there some easy way to test sendmail locally to see if there are issues with blocked ports? All the guides I find start out with several pages of configuration details.
What ports would sendmail need open to work? Do I need to expose additional ports on the container or on my firewall?
Shuo's answer worked for me except I changed:
supervisord reload # restart the service
to
supervisorctl reload
Another approach is to build your own Docker image and update the production.rb environment file. Here's what you're Dockerfile might look like.
FROM sameersbn/gitlab:7.14.0
MAINTAINER "leo.o'donnell#pearson.com"
# sed the production.rb environment file to use a configured email method converting
#
# config.action_mailer.delivery_method = :sendmail
#
# to
# config.action_mailer.delivery_method = (ENV['SMTP_DELIVERY_METHOD'] || :sendmail).to_sym
RUN sed -E -e "s/(action_mailer.delivery_method[^\:]+)([^ \t\#]+)(.*)/\1\(ENV\[\'SMTP_DELIVERY_METHOD\'\] \|\| \2\).to_sym\3/" -i config/environments/production.rb
or you can just use my image
docker pull leopoldodonnell/gitlab
I met the same problem yesterday and upvoted your question. Now I managed to make smtp work without send_mail.
sudo docker exec -it gitlab /bin/bash # go into the container
vi /home/git/gitlab/gitlab/config/environments/production.rb # The path may not exactly match, but you can guess
now search email and the method is :send_mail, change it to :smtp
supervisord reload # restart the service

redis server does not start

Hi I have the following problem with redis,
I have installed redis on Ubuntu 12.10 with
sudo apt-get install redis-server
However, then comes the start of the message server
[6793] February 6 21:46:54 # Warning: no config file specified, using the default config. In order to specify a config file use 'redis-server / path / to / redis.conf'
[6793] 6 February 6379 21:46:54 # Opening port: bind: Address already in use
What can I do that the server starts?
You should stop the current instance by using the following command.
/etc/init.d/redis-server stop
The default port for Redis, 6793, is already being used, so you'll need to find out what is using that port.
You can check by running: lsof -i :6793
You'll then need to either kill whatever is using that port or specify a different port for Redis using a config file.
pidof redis-server can get you the process id of redis-server;
OR lsof -i:6379 can get you the process id of the running instance with the default listening port 6379.
I would recommend you to check the log file for the troubleshooting possible errors.
Usually located at /var/log/redis/redis.log

pass kinit a custom krb5.conf file

I'm using kinit to log into a server that my sys admin didn't anticipate us using. It seems that the default location for the config file is /etc/krb5.conf, but I don't have root access so I can't edit this file to add a new server. How can I pass kinit a custom config file?
OK, solved the problem: the default config file location can be overridden by setting the KRB5_CONFIG environment variable
I had the same issue today. Here's the command that worked for me, for future reference:
env KRB5_CONFIG=/path/to/custom/krb5.conf kinit <your..args..here>
Try using
on Win
-Djava.security.krb5.conf=C:/IBM/IBMSSO/krb5.ini
on non Win
-Djava.security.krb5.conf=/opt/IBM/IBMSSO/krb5.conf
Example on Windows (with IBM Java)
java -Djava.security.krb5.conf=C:/IBM/IBMSSO/krb5.ini com.ibm.security.krb5.internal.tools.Kinit -k -t C:/IBM/IBMSSO/SSOICNTilo.keytab HTTP/myserver.123.com#123.COM

How to assign hostname to the web server?

I am using lighttpd as my webserver.
Currently I am accessing it using the IP address as :
http://192.168.0.1
I want to access it as
http://myhostname.com
I would be using it in the local network only, and not the internet.
I don't know how to do this. I googled, but don't know the exact keywords to use.
Put the following line to the file /etc/hosts:
192.168.0.1 myhostname.com
For instance, using the following command:
$ sudo echo -e '192.168.0.1\tmyhostname.com' >> /etc/hosts
you can add a rule in your hosts file: C:\Windows\System32\drivers\etc\hosts
add a rule like
192.168.0.1 myhostname.com
In windows you can't do this with wildcards so for all subdomains you need to add a rule
Find your hosts file on your local machine, and then add the following line to it:
192.168.0.1 www.somedomain.com