Jump to content

Recommended Posts

Posted

У меня такая проблема.У меня есть Keenetic Giga II с OPKG.При нормальном запуске(python <скрипт>.py &) всё нормально,но когда я добавляю в init.d файл для автозапуска(AGRS="python /opt/root/<скрипт>.py &") ,у меня пишет failed

Posted

Чуть подробнее, что в файле, логи полностью, и как запускаете.

Posted

Скрипт:

[spoiler=]

[code]# -*- coding: utf-8 -*-

from telegram.ext import Updater
import logging
import vk_api


logging.basicConfig(
       format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
       level=logging.INFO)

logger = logging.getLogger(__name__)
login, password = [не скажу]
vk_session = vk_api.VkApi(login, password)

try:
   vk_session.authorization()
except vk_api.AuthorizationError as error_msg:
   print(error_msg)


vk = vk_session.get_api()



def start(bot, update):
   bot.sendMessage(update.message.chat_id, text=[тоже не скажу])


def get_info(bot, update):
   chat_id = update.message.chat_id
   bot.sendMessage(chat_id, text='Подождите немного.Сбор информации.')
   info = vk.board.getComments([опятаки)['items']
   txtts = """"""
   for i in info:
       txtts = txtts + '\n' + i['text']
   bot.sendMessage(chat_id, text = txtts)
def error(bot, update, error):
   logger.warn('Update "%s" caused error "%s"' % (update, error))


def main():


   updater = Updater([можно догадаться])



   dp = updater.dispatcher


   dp.addTelegramCommandHandler("start", start)
   dp.addTelegramCommandHandler("help", start)
   dp.addTelegramCommandHandler("get_info", get_info)


   dp.addErrorHandler(error)


   updater.start_polling()


   updater.idle()

if __name__ == '__main__':
   main()

[/code]

Файл автозапуска:

[spoiler=]

#!/bin/sh

ENABLED=yes
PROCS=client2.py
ARGS=""
PREARGS="python ~/client2.py"
DESC=$PROCS
PATH=/opt/sbin:/opt/bin:/opt/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

. /opt/etc/init.d/rc.func

Запуск

[spoiler=]

[code]/opt/etc/init.d/S51client2] start
Starting client2.py...              failed.

[/code]

client2.txt

Posted

Понятнее не стало. Придется Вам лезть в rc.func и ковырять, расставлять отладку, пока не докопаетесь.

Posted

PROCS=client2.py
ARGS=""
PREARGS="python ~/client2.py"

Не правильно, надо так:

PROCS=python 
ARGS="/full/path/to/client2.py"
PREARGS=""

Или другой вариант: установить на файле client2.py атрибут исполяемой, а первой строкой в скрипте добавить shebang "#!/opt/bin/python". Тогда его можно будет исполнять непосредственно. Для этого случая скрипт в /opt/etc/init.d/Sxxmyscript будет выглядить как:

PROCS=/full/path/to/client2.py
ARGS=""
PREARGS=""

  • Thanks 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

This site uses cookies. By clicking "I accept" or continuing to browse the site, you authorize their use in accordance with the Privacy Policy.