Supervisor not detecting file - supervisord

I am trying to run a command via a proxy. When I run this command in shell it works
http_proxy=http://username:password#proxy:29800 /home/www/program -env prod
But when I put this into my supervisor config it tells me it can't find this file
[program:goprogram]
command = http_proxy=http://username:password#proxy:29800 home/www/program -env prod
directory = /home/www/program
enviroment=PATH='/home/www/env/bin:/usr/bin'
user = user
autorestart = true
Now, I assume it has to do with the http_proxy or syntax, but not sure how to fix it.

Since you are trying to set up an environment variable in the command itself, you might try a different way to call said command:
command = /bin/sh -c 'http_proxy=http://username:password#proxy:29800 home/www/program -env prod'
That way:
you don't have to add that environment variable to the environment section (or the credentials would be visible to all supervisord process' and child process’ environments)
you set http_proxy only for the command to be executed.

You need to set the http_proxy variable. Either the way #VonC described it or:
[program:goprogram]
command = home/www/program -env prod
directory = /home/www/program
enviroment=
PATH='/home/www/env/bin:/usr/bin'
http_proxy=http://username:password#proxy:29800
user = user
autorestart = true
More information can be found in this SO question.

Related

Setting up Clusters and work nodes - How do I set KUBECONFIG variable in Windows 10?

I using following link to create :
https://console.bluemix.net/docs/containers/cs_tutorials.html#cs_cluster_tutorial
In Lesson3, Step 3 "Verify that the KUBECONFIG environment variable is set properly.", I am unable to set the variable KUBECONFIG.
I am able to execute the following command:
ibmcloud ks cluster-config clusternameabc
I am getting following message
The configuration for clusternameabc was downloaded successfully. Export environment variables to start using Kubernetes, with the following message:
SET KUBECONFIG=C:\Users\AAA.bluemix\plugins\container-service\clusters\customernameabc\kube-config-hou02-clusternameabc.yml
When I run the above SET command in powershell, I just get the prompt back with environment variable not set.
When I do
$Env:KUBECONFIG=C:\Users\AAA.bluemix\plugins\container-service\clusters\customernameabc\kube-config-hou02-clusternameabc.yml
Notepad gets opened and this file is shown. I want to just set the environment variable and unable to. Can someone please tell me what I am doing wrong? I tried searching and could not find answers and IBM documentation has only Mac examples.
In Powershell
1) $env:KUBECONFIG = "C:\Users\AAA.bluemix\plugins\container-service\clusters\customernameabc\kube-config-hou02-clusternameabc.yml"
2) ls env:KUBECONFIG
Slightly easier to remember.
Based on my tests, you have to wrap the value of the environment environment in double quotes, like so:
$Env:KUBECONFIG="C:\Users\AAA.bluemix\plugins\container-service\clusters\customernameabc\kube-config-hou02-clusternameabc.yml"
Then, you can check the environment variables in PowerShell via this command:
Get-ChildItem Env:
Try this:
$Env:KUBECONFIG = ibmcloud cs cluster-config --export clusternameabc | Select -First 1 | % {$_.replace("SET KUBECONFIG=","")}

Configure VSTS to properly abort in case of errors

Given the following .vsts-ci.yml file
queue: Hosted Linux Preview
steps:
- script: |
false
true
The expected behavior and the actual behavior differ.
Expected behavior: Build fails at the false command, true will not be executed.
Actual behavior: Build succeeds, true is executed after the false command.
Details:
I would expect the VSTS build to fail on the first command false.
However, VSTS executes the second command true as well and reports success.
This means that the shell is setup incorrectly for build systems. The correct setup would be to have pipefail and errexit set. But it seems that errexit is not set, and probably pipefail isn't set either.
Is there a way to get the correct behavior, that is, pipefail and errexit, within the YAML file, without using bash -c in the scripts section? I know I can easily workaround by just moving the command sequence into a shell script or Makefile, I just want to know if there is a configuration possibility to get the YAML file execute shell commands in a shell with errexit and pipefail set, preferably a bash shell.
It seems that the bash shell created by VSTS does not have the pipefail and errexit flags set. See the following issue on GitHub about this: https://github.com/Microsoft/vsts-agent/issues/1803
But they can be set within the YAML file, like this:
queue: Hosted Linux Preview
steps:
- script: |
set -e ; set -o pipefail
false
true

Why Rundeck can't read custom remote node environment variables

I tried to run some commands on a remote node to test if Rundeck can display its environment variables, and it's weired that Rundeck can read the default env vars but not mine :
And result is :
I have defined my custom environment variables in different places (inside /etc/profile and ~/.bash_profile) but no luck..
Non interactive bash shell reads from .bashrc not .bash_profile. You might move your env var setting to .bashrc and source that file from .bash_profile.

How do I set an environment variable on Windows 10, which was generated from GitHub?

I want to make an updater for my Electron application, and I stuck on the GitHub access token.
I have generated a token from my GitHub account, and after that, I tried to set that token in my Windows environmental variables.
When I go to my application and I run this file publish.sh
publish.sh
#!/bin/sh
if [ -z "$GH_TOKEN" ]; then
echo "You must set the GH_TOKEN environment variable."
echo "See README.md for more details."
exit 1
fi
# This will build, package and upload the app to GitHub.
node_modules/.bin/build --win --mac -p always
I run this file ./publish.sh and I get this message:
You must set the GH_TOKEN environment variable.
I want to achieve step 4 and 5 in this example:
https://github.com/iffy/electron-updater-example
I tried to run this command from the Git Bash export GH_TOKEN="435468246872235283762846848267", but I get a return code of 0.
How do I set an environment variable on Windows 10, which was generated from GitHub?
Make sure to restart a new CMD session (in which you can type bash) in order to make sure your session does inherit the new Windows environment variable you have just set.
Once you have done that, you can check in the (new) Git Bash session which are the environment variables already set, with:
env
env | grep GH
Make sure your script starts with
#!/bin/bash
The OP George points out in the comments that the correct form is:
export GH_TOKEN=MY_VARIABLE_NAME
(no double quotes)

Executing subprocess.Popen inside Python script in PyDev context is different than running in terminal

I'm executing this code:
p = subprocess.Popen(['/path/to/my/script.sh','--flag'] , stdin=subprocess.PIPE)
p.communicate(input='Y')
p.wait()
It works when executing it on the shell using "python scriptName.py",
BUT when executing using PyDev in Eclipse, it fails, the reason:
/path/to/my/script.sh: line 111: service: command not found
This bash script "script.sh" contains the following command which causes the error:
service mysqld restart
So "service" is not recognized when running the .sh script from the context of PyDev.
I guess it has to do with some ENV VAR configurations, couldn't find how to do it.
BTW - Using "shell=True" when calling subprocess.Popen didn't solve it.
service usually is located in /usr/sbin, and that this directory isn't on the PATH. As this usually contains administrative binaries and scripts which arn't designed to be run by everyone (only by admins/root), the sbin directories arn't always added to the PATH by default.
To check this, try to print PATH in your script (or add an env command).
To fix it, you could either
set the PATH in your python script using os.setenv
pass an env dict containing the correct PATH to Popen
set the PATH in your shellscript
use the full path in your shellscript
set the PATH in eclipse