etcd unknown job when start service - etcd

I have the next etcd.conf, and if I try to start the etcd service with the next command, it throws the next:
ubuntu$ service etcd start
start: Unknown job: etcd
etcd.conf
# vim:set ft=upstart ts=2 et:
description "etcd"
author "etcd maintainers"
start on stopped rc RUNLEVEL=[2345]
stop on runlevel [!2345]
respawn
setuid etcd
env ETCD_DATA_DIR=/var/lib/etcd
export ETCD_DATA_DIR
exec /usr/bin/etcd --name="client1"\
--advertise-client-urls="http://172.16.8.244:2379,http://172.16.8.244:4001"\
--listen-client-urls="http://0.0.0.0:2379,http://0.0.0.0:4001"
--listen-peer-urls "http://0.0.0.0:2380"\
--initial-advertise-peer.urls "http://172.16.8.244:2380"\
--initial-cluster-token $(uuidgen)\
--initial-cluster "cient2=http://172.16.8.244:2380"\
--initial-cluster-state "new"

The error message has nothing to do with etcd, but caused by upstart script.
When got message like start: Unknown job, there must be something wrong in upstart script. In your case:
--listen-client-urls="http://0.0.0.0:2379,http://0.0.0.0:4001"
--listen-peer-urls "http://0.0.0.0:2380"\
I think what you want is (miss the character '\' at the end of first line):
--listen-client-urls="http://0.0.0.0:2379,http://0.0.0.0:4001"\
--listen-peer-urls "http://0.0.0.0:2380"\
You can try it again after you correct this.

Related

Troubleshooting PM2 Restart in Cron

Update: I was not able to get this working as I desired. I ended up using the pm2 --cron flag since cron couldn't find my pm2 processes.
I am using pm2 restart in a bash script and it always fails on the pm2 restart projectName commands when run by cron (as root) but works when run manually with sudo. I am not sure how to troubleshoot as the pm2 log files don't show anything obvious. It looks like someone else has had the same issue so perhaps it's just a bug? Has anybody else found a way to resolve this issue?
Thank you!
Edit: Adding some context for #kevinnls
Here's the .sh script; I've isolated the command so I can test cron
# Vars
NOW=$(date +"%Y-%m-%d")
LOGS_PATH="/scriptLoc/logs"
LOG_FILE="$LOGS_PATH/$NOW-log.txt"
BE_PATH="/beLoc"
# Start log file
date >> $LOG_FILE
echo "Running..." >> $LOG_FILE
# Temp
cd $BE_PATH
pm2 restart be >> $LOG_FILE
pm2 restart be || echo "ERROR: BE pm2 restart: $?" >> $LOG_FILE
echo "Done." >> $LOG_FILE
exit
If I run the command with sudo ./script.sh it works
If I run it with cron I see the following output in my log file:
Fri Mar 26 17:35:01 UTC 2021
Running...
Use --update-env to update environment variables
ERROR: BE pm2 restart: 1
Done.
If I view pm2 logs:
I see it exit with code 0 and restart when I run the script manually.
I see no output for the failed restart from cron
The error you got:
[PM2][ERROR] Process or Namespace be not found
What is "be"? seems like pm2 from inside of cron has no idea what to make of it.
If it is a file, when you ran the script in your shell, was the file be in your working directory?
You can make these changes to log your error messages to $LOG_FILE.
This should help you get more details.
#redirect output *and* errors to log
pm2 restart be &>> $LOG_FILE
exit_code=$?
# if previous exit code != 0 do everything after `&&'
[[ $exit_code -ne 0 ]] && echo "ERROR: BE pm2 restart: $exit_code" >> $LOG_FILE
Then try running your script again and share the errors encountered.
I was not able to resolve this in the manner I desired. Ultimately I used the -c (cron) flag with pm2 itself.
pm2 cli reference
gitlab issue

Kubernetes postStart lifecycle hook exited with 7

I have a simple bash script to execute at postStart, but i get an error which is not informative at all:
Exec lifecycle hook ([/bin/bash -c sleep 30;/xcom/scripts/sidecar_postStart.sh]) for Container "perfcibuddy" in Pod "xcomapp-597fb859c5-6r4g2_ns(412852d1-5eea-11ea-b641-0a31ddb9a71e)" failed - error: command '/bin/bash -c sleep 120;/xcom/scripts/sidecar_postStart.sh' exited with 7: , message: ""
The sleep is there because I got a tip that there might be a race condition, that the script is not in place at the time Kubernetes calls it.
And if I log into the container I can execute the script from the shell without any problem.
The script is just doing a simple curl call (IP obviously sanitized):
# ----------------------------------------------------------------------------
# Script to perform postStart lifecycle hook triggered actions in container
# ----------------------------------------------------------------------------
# -------------------------------------------[ get token from Kiam server ]---
role_name=$( curl -s http://1.1.1.1/latest/meta-data/iam/security-credentials/ )
curl -s http://1.1.1.1/latest/meta-data/iam/security-credentials/${role_name}
I tried numerous form to set the command in the template (everything in quotes, with && instead of ;), this is the current one:
exec:
command: [/bin/bash, -c, "sleep 120;/xcom/scripts/sidecar_postStart.sh"]
What could be the problem here?
Curl exit code 7 is generally “unable to connect” so your IP is probably wrong or the kiam agent is not set up correctly.

Ubuntu upstart script error

I am getting an error:
init: zeus main process (1636) terminated with status 1
when i try to run my very simple upstart script which looks like this:
#!upstart
description ""
author ""
script
cd /home/ubuntu/zeus
xvfb-run node --harmony www
emit zeus_running
end script
Any ideas on what the actual problem is? I have added a pre-stgart and post-start script section with logs and I have confirmed that it is failing in the main script that i have posted here.

Shell script to call daemon - DAEMON: command not found

Currently I can start a custom server like this:
cd /home/admin/service/build && ./service visual.dat
I'm trying to make a shell script to make a daemon. I tried many things...
#!/bin/sh -e
cd /home/admin/service/build
DAEMON = "./service"
daemon_OPT="service.dat"
...
The response is:
admin#service:~$ sudo /etc/init.d/servicedaemon start
/etc/init.d/servicedaemon: line 3: DAEMON: command not found
Well, how to launch the service from the daemon like I did from the shell ? It's probably a path issue.
Thanks in advance.
I think you have to remove the spaces around "=":
DAEMON="./service"
Now it seems that it tries to run a command called DAEMON instead of the actual application.

start-stop-daemon: pass arguments to application (vertx)

I'm trying to build an upstart configuration that's used in combination with monit.
I'd like to pass some arguments to vertx as well (multiple instances of the verticle), but I'm failing to get a proper statement on the shell already, so I think there's no need to quote the upstart script.
start-stop-daemon --start --chdir /my/app/dir --exec /usr/bin/vertx runzip myverticle-mod.zip -instances 20
No idea how to pass the '-instances 20' arg to the exec statement, somehow it is always interpreted as option to start-stop-daemon
start-stop-daemon: invalid option -- 'i'
I already tried putting the whole --exec statement into braces...
Maybe I missed something in Unix basics and didn't manage to properly escape the --exec string, so my pragmatic approach/workaround was creating a custom parameterized start script:
#!/bin/sh
export JAVA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=$1 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=192.168.0.100"
/usr/bin/vertx runzip $2 -instances $3
Upstart config (running 10 instances of a verticle via JMX RMI on port 33002)
script
VERTX_OPTS=" 33002 mymodule-mod.zip 10"
exec start-stop-daemon --start --exec /usr/bin/myVertxStartup --$VERTX_OPTS
end script

Resources